Decompile all the jar files in given directory

dhanushkadev

Dhanushka madushan

Posted on January 12, 2023

Decompile all the jar files in given directory

Procyon is a Java decompiler for reverse engineering compiled Java code. It can be used to decompile Java 5 and Java 7 bytecode and is open-source. Procyon's ability to decompile complex Java code and generate comprehensible output is one of its benefits. Decompiling JAR files is one of Procyon's common uses. The file format known as a JAR file, or Java Archive, is used to store multiple files, including Java classes and resources, in a single archive. Typically, these files are turned into Java bytecode, which can then be run on any Java Virtual Machine (JVM).

You must first download the Procyon decompiler file from the official website and put it in a directory on your system before you can use Procyon to decompile a JAR file. After that, you can run the JAR file from the command line while specifying the JAR file you want to decompile as an argument. For instance, the "example.jar" JAR file can be decompiled using the following command:

java -jar procyon-decompiler.jar example.jar
Enter fullscreen mode Exit fullscreen mode

By doing this, all of the class files in the JAR file will be extracted, and the decompiled source code will be written to separate files with the same name as the class file but a.java extension. The JAR file and the decompiled code will both be kept in the same directory.

You can use Procyon decompiler and have a recursive look into folders with the following command.

find <jar_files_directory> -name "*.jar" -exec java -jar <procyon_decompiler_location> -jar {} -o <output_directory> \;
Enter fullscreen mode Exit fullscreen mode

Example

find . -name "*.jar" -exec java -jar /Users/abc/Desktop/procyon-decompiler-0.6.0.jar -jar {} -o output/ \;
Enter fullscreen mode Exit fullscreen mode

It's important to keep in mind that Java code decompiling is not always correct, and the resulting source code might not exactly match the original. Decompiling Java code may also be permitted in some circumstances, but it frequently violates copyright regulations, so it should be used with caution.

Procyon is a powerful resource for debugging Java code and has a wide range of applications. Procyon is a dependable decompiler that can assist you in achieving your objectives, whether you're looking to comprehend how a third-party library operates or recover lost source code.

💖 💪 🙅 🚩
dhanushkadev
Dhanushka madushan

Posted on January 12, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related