javadlljarikvm

Converting dll to jar


I'm trying to find a way to convert a dll to a jar file. I have a .net application that communicates with a java application. The core entities are .net objects which I have to duplicate manually in java. I've read about IKVM but it seems that it converts only jars to dlls and not the other way around.

Edit: If there is a tool that creates java classes from a dll it is also fine. Thanks in advance


Solution

  • There isn't such a tool.

    A dll is a natively compiled library. That means its been compiled down to machine code. Probably compiled by a C/C++/C# compiler.

    A jar file is a zip file that contains '.class' files, which are files compiled down to 'java virtual machine code'. Probably compiled by a java/clojure/scala compiler.

    These are two very different incompatible things.

    It's not impossible to create such a tool that would do this translation, but it would definitely be an extremely difficult task, as it would entail translating from one machine code, to another, and would need to manage multiple issues like dependency solving, different type structure etc.

    HOWEVER, I'm imagining that you want to do this because you want to use a DLL within some java code. That is somewhat possible, but is actually quite complicated. You'll need to use the JNI.

    Take a look at this question as it might help you achieve what you want to do: Calling C++ dll from Java