32

I'm trying to figure out how to use the Fernflower Java decompiler.

I can find java-decompiler.jar at the following location:

~/idea-IC-162.1628.40/plugins/java-decompiler/lib/java-decompiler.jar

There is no fernflower.jar, however. I assume this is because the functionality has been folded into java-compiler.jar, and the Fernflower README has simply not been updated in 2 years.

When I run the following, however:

java -jar ~/idea-IC-162.1628.40/plugins/java-decompiler/lib/java-decompiler.jar myclassfile.class .

I get

no main manifest attribute, in /home//idea-IC-162.1628.40/plugins/java-decompiler/lib/java-decompiler.jar

Has IntelliJ stopped supporting command-line based decompilation, or am I missing something here?

Tianxiang Xiong
  • 3,887
  • 9
  • 44
  • 63

1 Answers1

44

Try to invoke main class org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler manually

java -cp java-decompiler.jar org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler myclassfile.class .

Also you can find more about internal usage of Fernflower inside IDEA by query in source code https://github.com/JetBrains/intellij-community/search?utf8=%E2%9C%93&q=Fernflower

qwazer
  • 7,174
  • 7
  • 44
  • 69
  • 2
    Great, this works. TIL about the difference between [executable and non-executable JARs](http://stackoverflow.com/a/9689868/864684). – Tianxiang Xiong Nov 19 '16 at 02:16
  • 4
    You can also decompile jar files and folders by passing them instead of a class file. – Jesus H Jul 09 '19 at 15:52
  • @JesusH Thanks, I try and worked. `java -cp java-decompiler.jar org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler '.\org-demo-push-0.0.1-SNAPSHOT.jar' push` – Leo Lee Oct 21 '22 at 10:53