Converting dll to jar

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


This is actually an easy task to perform. Converting .dll to .jar is as simple as using com4j and a couple of commands on the command line.

  1. Download com4j.
  2. Open command line and navigate to com4j directory in above step.
  3. Execute below command.

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

  1. Then jar the results with the following:

    jar cf desiredJarName.jar folderYouWantJard

Tags:

Java

Ikvm

Dll

Jar