Click here to Skip to main content
15,902,635 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to make c# dll compatible with java??
Posted

1 solution

It depends on what you call "Java". If Java is just the language, there are products which would enable you to use Java as a .NET language. Please see:
http://en.wikipedia.org/wiki/.NET_languages[^].

If by "Java" you mean something which works with Java Virtual Machine (http://en.wikipedia.org/wiki/JVM[^]), roughly speaking, there is no compatibility.

Theoretically speaking, it's possible to make some interoperability bridge, but this is such a long way that I would hate to discuss it in detail. I don't think it can make any practical sense. I don't know if such projects exist. In brief, you can automatically re-build a .NET assembly the way that it can export some static methods as unmanaged. In pure C# this is not possible, but CIL standard allows it. There are few CodeProject articles explaining how to do it, complete with the code which uses ILDASM and ILASM (IL Assember and Disassembler) under the hood. This is itself a very interesting topic (many developers claim this is not possible, but this is not true), but this is only one of the required steps. The alternative way would be using one more work-around state with COM. As a result, you could have either a mixed-mode assembly (managed+unmanaged) or a COM DLL and use it with Java through JNI (http://en.wikipedia.org/wiki/JNI[^], http://electrofriends.com/articles/jni/jni-part1-java-native-interface/[^]).

I cannot imagine a fully sober developer who would volunteer to go into all this mess. CLR and Java are two different words; they have a lot of in common but are much more distant from each other than either Java or CLR on very different platforms.

[EDIT]

However, please see this recent answer: can we reuse DLL developed in C# in java projects[^].

—SA
 
Share this answer
 
v3
Comments
Prasad_Kulkarni 23-May-12 0:20am    
Good answer SA! +5!
Sergey Alexandrovich Kryukov 23-May-12 0:58am    
Thank you, Prasad.
--SA
TorstenH. 23-May-12 1:41am    
nice answer - but I guess the questioner is not able to use it. Let's see.
Sergey Alexandrovich Kryukov 23-May-12 10:07am    
Yes, this was actually my idea, otherwise I would provide more detail. Maybe the answer by Manfred R. Bihy would be much more realistic. This is nearly the same thing, but the project is already available; I just did not know about it.
Thank you.
--SA
JANARDHAN GURRAM 25-May-12 12:06pm    
Thanks SAKryukov for the detailed explanation..
links u provided also give good information thank you..
but i think there will be a way definitely though little complex..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900