Re: Java - C# interop

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: SirThanxALot (sirthanxalot_at_spymac.com)
Date: 02/08/05


Date: Tue, 08 Feb 2005 10:57:39 +0100

Thanx for the most informing reply.
So now it comes down to this:

I need to the C# in Java thingy.
For now, I see the JNI dll writing in C# as a last resort.
I'd better make a VC++ wrapper/bridge

something like
java <-1-> jni <-2-> c++ <-3-> C#
parts 1 and 2 are ok for me
3 remains an issue as Thomas Fritsch stated

I just want to do this. Ihave made a class in C#
I want to create an instance of it (from within C++) and invoke
methods on it.

Thanx,
srtnxalt

Alessandro Angeli [MVP::DigitalMedia] wrote:
> SirThanxALot wrote:
>
>
>>Is there a way for interop between C# and Java?
>
>
> JAVA IN C# 1. You can register your Java classes as COM
> objects using the ActiveX Bridge in the JDK and then use COM
> InterOp.
>
> JAVA IN C# 2. Use P/Invoke to use the JNI invocation API and
> System.Reflection.Emit to call the native JNI funtions in
> the JNIEnv structure. This is a hack, it's difficult and
> practically undocumented.
>
> C# IN JAVA. You can write a JNI DLL in C# by using
> System.Reflection.Emit to call the native JNI funtions in
> the JNIEnv structure and then usng ILDasm and ILAsm to
> create exported JNI functions from the C# DLL. This is a
> hack, it's difficult and practically undocumented.
>
>
>>Is it possible to use the JNI with C#
>>Or do I have to do a workaround with (V)C++?
>
>
> Using mC++ is a lot easier. You can think of creating a JNI
> wrapper in mC++ instead of writing it all in mC++.
>
> There are a couple of Java/.NET interop libraries somewhere
> on the web.
>
> You can also just create the Java part and the .NET part in
> 2 separate processes and then use socket streams to make
> them communicate.
>
>



Relevant Pages

  • Re: Apple is deprecating Java
    ... JNI and JNA leave a bit to be desired... ... large portion of the app is written, say, in C and C++, and Java or C# is ... moving the interface gunk onto the Java side of things is not ideal either ... public native void set ...
    (comp.lang.java.programmer)
  • Re: JNI RegisterNatives from java side
    ... > I am looking for an equivalent of RegisterNatives method in JNI which ... > can be used in java and not C. ... there is this JNI dll which has a standard java ...
    (comp.lang.java.programmer)
  • Re: Clear the Screen
    ... cannot be implemented in any standard way across platforms. ... Even the 'standard' C and C++ languages which, like Java, aim for platform ... do not implement such functionality. ... of a development commitment needs be made by using JNI. ...
    (comp.lang.java)
  • Re: Opinions on complexity
    ... Java because it is the language I know the best. ... The only thing I was asking for, was some advice on the TCP/IP stack implementation. ... and combined with the RFCs for the protocol will speed your development. ... But, if Java is your choice, you really only need to JNI the low level socket functions that give you access to the interface device, writing you protocol stack in pure java. ...
    (comp.lang.java.programmer)
  • Re: Java - C# interop
    ... I need to the C# in Java thingy. ... I see the JNI dll writing in C# as a last resort. ... >>Is there a way for interop between C# and Java? ...
    (comp.lang.java.programmer)