简体   繁体   中英

Java / NetBeans - How to Step into a jar file?

I have a Java project in Netbeans with several jar files listed in its library section of properties.

I found a bug in one of the jar files and I want to step into it while debugging.

Here's what I've done so far:

  1. I've found the source code for the jar file.
  2. I opened that source as a project in NetBeans (it comes as a NetBeans project)
  3. I deleted that jar file from the compile-time libraries section of my project.
  4. I added the new project in the compile-time libraries section of my project using "add project".
  5. Did a clean and build on the new project, and on my project.

It builds and runs the same as before but I still can't step into the new project's code. But when I try to step into a method in the new project Netbeans says "cannot open (missing source?)". I also tried to set a breakpoint in the new project's method but Netbeans says "Not able to submit breakpoint LineBreakpoint ObjectMakerFactory.java : 203, reason: No executable location available at line 203 in class ...."

Make sure you set the break point in the correct file that is actually deployed (make sure it's in the correct project), if you have multiple projects open.

Additionally, make sure under windows/debugging/sources that your source root is also enabled. In some versions this gets enabled by default, in others you have to add the source root and enable it with the checkbox.

I cant say for netbeans, but for Eclipse and IntelliJ I've always had success downloading the src jar and adding it to the project. Then, in my code when I click into the method for a class in the jar the IDE brings me to the source. If that is happening, you can set breakpoints in the src and proceed as normal.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM