Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Source not found when debugging constructor

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!

like image 274
Actiyv Avatar asked Jul 31 '26 05:07

Actiyv


1 Answers

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).

like image 87
Pace Avatar answered Aug 01 '26 17:08

Pace



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!