Issue
I'm very confused. I downloaded a *.jar file as a bit of software. So, I would like to extract the source code to look at it
I used the command jar xf filename.jar
which returned two more *.jar
files and a *.class
file. I still cannot open these in the terminal with standard text editors.
Perhaps this is not open source software? Is there an alternative to see what has been done here?
Solution
- Download FernFlower.jar: https://the.bytecode.club/fernflower.jar //the fernflower.jar site changed from http to https
- Documentation: http://the.bytecode.club/fernflower.txt
- Repository: https://github.com/JetBrains/intellij-community/tree/master/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler
Run "java -jar fernflower.jar -dgs=true JarToDecompile.jar DecompiledJar
"
This is what Intelli-J & Android-Studio Decompiler does.
Note: Fernflower extracts the .java
files to a .jar
file. You can either Unzip the jar file as a regular zip file (if your version of Archive Utility
on OSX allows it -- It doesn't do it for me on OSX Sierra but works on El Capitan) OR you can do jar xf DecompiledJar
and it'll extract it.
Example (all in one command -- multiple commands separated by &&
):
java -jar fernflower.jar -dgs=true JarToDecompile.jar DecompiledJar && cd DecompiledJar && jar xf DecompiledJar.jar && cd ../
Answered By - Brandon
Answer Checked By - Pedro (JavaFixing Volunteer)