Convert dll to jar

I am trying to find a way to convert dll to jar file. I have a .net application that interacts with a Java application. The main objects are .net objects, which I have to duplicate manually in java. I read about IKVM, but it seems that it only converts jars to dll, and not vice versa.

Edit: if there is a tool that creates java classes from dll, this is also fine. thanks in advance

+5
source share
3 answers

There is no such tool.

dll is a natively compiled library. This means that it was compiled to machine code. Probably compiled by the C / C ++ / C # compiler.

A jar file is a zip file containing ".class" files, which are files compiled to "Java Virtual Machine Code". Probably compiled by the java / clojure / scala compiler.

These are two very different incompatible things.

It is impossible to create such a tool to perform this translation, but it would definitely be an extremely difficult task, since it would entail a translation from one machine code to another, and it would have to manage several problems, such as the decision about dependency, structure another type, etc.

HOWEVER, I imagine that you want to do this because you want to use the DLL in some kind of Java code. This is somewhat possible, but actually quite difficult. You will need to use JNI.

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

+4
source

This is actually a simple task. Converting a .dll to a .jar is as simple as using com4j and several commands on the command line.

  • Download com4j.
  • Open a command prompt and go to the com4j directory in the previous step.
  • Run the command below.

java -jar tlbimp.jar -o outputFolder -p nameOfPackage "pathToFile"

  1. Then collect the results with the following:

    jar cf wishJarName.jar folderYouWantJard

+2
source

Yes, there is a tool to convert the .net file dll to jar file. Site name enter link description here https://javonet.io/

0
source

Source: https://habr.com/ru/post/1484079/


All Articles