How to decompile and debug a .jar file?

Answered

I am trying to decompile and debug a .jar file with IntelliJ IDEA 2022.1.2 (Ultimate Edition). I have two issues:

  • I open the folder the .jar file is located in, but I don't see an option to decompile or inspect the content of the .jar file. I noticed that in regular source code projects, IntelliJ seem to do that automatically for dependencies.
  • The concerning .jar file can only be run using java -cp "./myclasspath/*" com.package.identifer.MyClassName. When creating a run configuration, it seems like "JAR Application" only supports java -jar. How can I run and debug my jar file in IntelliJ using java -cp?

In the end, I want to be able to run a .jar file and set break points.

 

0
1 comment

Hi there,

I don't see an option to decompile or inspect the content of the .jar file

Option one: 

  1. Open an existing project or create a new one.

  2. Go to Project structure settings > Libraries. Add the jar you want to decompile in libraries by clicking the + symbol.

  3. Go to the Project tool window shown on the left. Search for jar name that you added in the previous step. Navigate to the desired class or package. You will be able to see the decompiled java files for that jar.

Option two is to use third-party plugins like Archive Browser and File Expander.

See also https://stackoverflow.com/questions/45959594/debug-jar-intellij-or-command-line

1

Please sign in to leave a comment.