0

I've received a java dll file with an app I've downloaded. This DLL file was written in Java and now I want to decompile it.

Here is how I call this dll that contains a jar:

new JarInputStream(getClass().getResourceAsStream("jarjava.dll"));

Is there a way to decompile it?

David
  • 363
  • 1
  • 4
  • 19
Manitoba
  • 8,522
  • 11
  • 60
  • 122
  • 1
    Are you sure the dll file is created from java? Did you ever heard about JNI (Java Native Interface)? Actually the dll file is create from C/C++. – Crazenezz Apr 16 '12 at 09:08
  • Yep: http://stackoverflow.com/questions/262603/is-there-any-way-to-compile-java-code-into-a-dll – Manitoba Apr 16 '12 at 09:13

3 Answers3

1

Java source files are compiled to .class files. As far as I know, there is no standard way to compile java code to a DLL.

What could have happened here:

  • This is C code written against the JNI API, to be used to interact with (or from) Java code;
  • This is Java code that was (automatically) converted to C code by some tool, and then compiled to a DLL.
  • This is a JAR file that someone renamed to a DLL. In that case, rename it back, unzip the JAR, and decompile the JAR with a Java decompiler.

Without knowing something about the origin of this DLL, there's not much you can do. Try a C decompiler, but probably won't get very far.

Wouter Lievens
  • 4,019
  • 5
  • 41
  • 66
  • It is possible: http://stackoverflow.com/questions/262603/is-there-any-way-to-compile-java-code-into-a-dll – Manitoba Apr 16 '12 at 09:14
0

You can read the machine code and translate it back into C yourself. Its not easy as the the whole point (possibly only point) of compiling the code to native is to make it harder to decompile.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
0

Problem solved.

Here it how I did it:

Read the file:

JarInputStream input = new JarInputStream(getClass().getResourceAsStream("/myjar.dll"));

Write a new file for each entry:

JarEntry entry;
while ((entry = input.getNextJarEntry()) != null)
{
    // Write file
}
Manitoba
  • 8,522
  • 11
  • 60
  • 122