Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to decompile a jar into .java files from command prompt

How can I decompile a JAR (.class binary files) into .java source files from command prompt?

like image 340
Karuna Avatar asked Feb 22 '16 21:02

Karuna


People also ask

Can we convert JAR file to Java?

How to Convert a JAR File. You can decompile a JAR file's CLASS files to Java files with the help of JavaDecompilers.com.

How do I get a .Java file from a .class file?

You can use a decompiler to do so. One of the most major ones is JD-GUI. JD-Core is a library that reconstructs Java source code from one or more “. class” files.

How do I decompile a Java file?

In order to decompile class file, just open any of your Java projects and go to Maven dependencies of libraries to see the jar files included in your project. Just expand any jar file for which you don't have the source attached in Eclipse and click on the . class file.

Can a JAR file be decompiled?

Unless you explicitly packaged your source code in the JAR file, there's no way to get back the original source. You could try using a decompiler (like this) but that will hardly give you nice, readable code. The best solution would be to stop using your computer right now.


1 Answers

I found that jd-cmd does the job just fine, and works recursively in sub-folders for multiple files. To decompile a group of files on the command line, run the following commands:

  1. Download the JAR file from here as the jd-cmd README.md file.
  2. Create the directory where your output Java files will be located.
  3. Run the command to decompile the files: java -jar jd-cli.jar -od <my-output-folder> <my-input-folder>.
like image 71
entpnerd Avatar answered Sep 16 '22 11:09

entpnerd