Eclipse java debugging: source not found Eclipse java debugging: source not found java java

Eclipse java debugging: source not found


Just 3 steps to configuration Eclipse IDE:

Note: After updating the Source Lookup paths, you'll have to stop and restart your debug session. Otherwise, the file with the missing source will continue to show "missing source".

Edit Source LookupSelect the Edit Source Lookup... command [ Edit Source Lookup ] to open the Source Path Dialog, which allows you to make changes to the source lookup path of the selected debug target.

enter image description here

enter image description here

enter image description here

IMPORTANT Restart Eclipse after this last step.


Eclipse debugging works with the class actually loaded by the program.

The symptoms you describe sounds like the class in question was not found in the project, but in a distribution jar without debug info found before the project you are working with.

This can happen for several reasons but have a look at the location where the classes showing this behaviour is found (look in the navigation pane to identify it). You will most likely need to change the build path of the project to avoid using this jar and have the JVM use the project instead.

EDIT: Note that as of 2018 it is common to use a build framework like Maven, where the build path is managed by the m2e plugin so this problem should be very less frequent than when the question was asked. If you use Maven and m2e, make sure to enable Preferences / Maven / "Download Artifact Sources" or right-click the project, Maven / "Download Sources".


The symptoms perfectly describes the case when the found class doesn't have associated (or assigned) source.

  • You can associate the sources for JDK classes in Preferences > Java > Installed JRE. If JRE (not JDK) is detected as default JRE to be used, then your JDK classes won't have attached sources. Note that, not all of the JDK classes have provided sources, some of them are distributed in binary form only.
  • Classes from project's build path, added manually requires that you manually attach the associated source. The source can reside in a zip or jar file, in the workspace or in the filesystem. Eclipse will scan the zip, so your sources doesn't have to be in the root of the archive file, for example.
  • Classes, from dependencies coming from another plugins (maven, PDE, etc.). In this case, it is up to the plugin how the source will be provided.
    • PDE will require that each plugin have corresponding XXX.source bundle, which contains the source of the plugin. More information can be found here and here.
    • m2eclipse can fetch sources and javadocs for Maven dependencies if they are available. This feature should be enabled m2eclipse preferences (the option was named something like "Download source and javadocs".
    • For other plugins, you'll need to consult their documentation
  • Classes, which are loaded from your project are automatically matched with the sources from the project.

But what if Eclipse still suggest that you attach source, even if I correctly set my classes and their sources:

This almost always means that Eclipse is finding the class from different place than you expect. Inspect your source lookup path to see where it might get the wrong class. Update the path accordingly to your findings.

Eclipse doesn't find anything at all, when breakpoint is hit:

This happens, when you are source lookup path doesn't contain the class, which is currently loaded in the runtime. Even if the class is in the workspace, it can be invisible to the launch configuration, because Eclipse follows the source lookup path strictly and attaches only the dependencies of the project, which is currently debugged.

An exception is the debugging bundles in PDE. In this case, because the runtime is composed from multiple projects, which doesn't have to declare dependencies on one another, Eclipse will automatically find the class in the workspace, even if it is not available in the source lookup path.

I cannot see the variables when I hit a breakpoint or it just opens the source, but doesn't select the breakpoint line:

This means that in the runtime, either the JVM or the classes themselves doesn't have the necessary debug information. Each time classes are compiled, debug information can be attached. To reduce the storage space of the classes, sometimes this information is omitted, which makes debugging such code a pain. Your only chance is to try and recompile with debug enabled.

Eclipse source viewer shows different lines than those that are actually executed:

It sometimes can show that empty space is executed as well. This means that your sources doesn't match your runtime version of the classes. Even if you think that this is not possible, it is, so make sure you setup the correct sources. Or your runtime match your latest changes, depending on what are you trying to do.