Search code examples
javaeclipsedebuggingworkspacebuildpath

Eclipse Java Debugger Source Lookup Path


I have two Java eclipse projects in my workspace. Project ProjectA has class ClassA inside package packageA, and likewise, project ProjectB has class ClassB inside package packageB.

I have this simple code:

// ClassA.java
package packageA;

import packageB.ClassB;

public class ClassA {

    public static void main(String[] args) {
        ClassB b = new ClassB();
        String str = b.getStr();
        System.out.println(str);
    }

}


// ClassB.java
package packageB;

public class ClassB {
    private String str;

    public ClassB() {
        str = "Hello, World!";
    }

    public String getStr() {
        return str;
    }
}

The Problem: I am trying to debug main in ClassA. When I step into the ClassB constructor, I get the error "Source not found" with the button "Edit Source Lookup Path...". I tried to fix this by adding ProjectB to the "Source" tab of ProjectA's debug configurations, but still getting the same error.

The question: How do I fix this issue?


Solution

  • I solved this issue as follows: When I encounter the "Source not found" page, I step out with the debugger a few times, until I get back to where I was in my code. Then, I step into again, and this time it works.

    For reference, please see this answer.