Search code examples
javashelldebuggingintellij-ideajar

Debug JAR intellij or command line


Im using the following config the debug jar file that under my root project, when I click on debug the program start to run but doesnt stopes since I didn't set any break-point(as this is jar file :) ) , In node.js there is option to do it with --inspect-brk info which stops on the first statement but not sure How to do it on jar file

My questions are

  1. How can I stops in the first line of the program jar ?
  2. Does my config are OK?

enter image description here

Oterwise , how can you able to debug jar if you cannot set a break-point ...

EDIT:

I've tried with the suggestion of crazycoder and it's not working, any idea?

What I tried is to create under my root project decomplie folder and run the following command

 java -jar fernflower.jar zte.jar + decomplie/

I got erorr of course of not found

I've also tried with

java -cp java-decompiler.jar org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler zte.jar + decomplie/ 

Could not find or load main class org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler

How to I get this jar (fernflower.jar ) or the path to it ?

EDIT2

My project is like this

-myjavaproj

 --zte.jar
 --decomile
 ---zte.jar
 ---com.proj.cli
 ----appmain.java 

Solution

  • For your specific project that is one jar file (zte.jar) which contains deps.zip inside which in turn contains other .jar dependencies and no sources at all and also uses reflection and custom classloader in order to load and use the .jar files in deps.zip; for the debugger to work, you have to unpack all the jars from the deps.zip into some location, then make a new IntelliJ IDEA project and add all the jars (including the root zte.jar and all the jars unpacked from deps.zip) into the module dependencies.

    Browse to CliExecutor inside the self.jar, in the project view, IntelliJ IDEA will decompile it, place the breakpoints, debug it.