开发者

Source not found when debugging constructor

开发者 https://www.devze.com 2023-03-22 08:37 出处:网络
I am an experienced .NET and Visual Studio developer who\'s trying to switch to Java and Eclipse. I am a newbie to Eclipse.

I am an experienced .NET and Visual Studio developer who's trying to switch to Java and Eclipse. I am a newbie to Eclipse.

I am having a hard time debugging my Java programs. The "step into" debugging function always results in a "Source not found" error message with an "Edit Source Lookup Path" button whenever I 开发者_如何学运维try to step into a constructor. I've just installed Eclipse Enterprise Edition and not messed around with any settings.

Even debugging inner classes results in this error. Consider this code:

public class HelloWorld {   
  public static void main(String[] args) {
        class JustForTesting {
        public String s;
        public JustForTesting() {
        s = "Just a test";
        }
    }   
    JustForTesting n = new JustForTesting();
     System.out.println("Hello World! " + n.s);
  }
}

If I put a breakpoint at line 9 and try to step into the constructor (line 5) it says "Source not found". The title of the window is Launcher$AppClassLoader(ClassLoader).loadClass(String) line: 24 Quite unbelievable as the code obviously resides in the same file!


It's not so much an Eclipse thing and more of a Java thing. When you construct any class for the first time Java needs to load the class. If you get into that situation again just do a step-return (this will finish loading the class) and then do step-into again (this will go into your constructor).


Just Below Source not found error you will see "Edit Source Lookup Path" button click on it and then click on Add button then Java Project and include your project .. Hope this will solve your problem

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号