3

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!

ztirom
  • 4,382
  • 3
  • 28
  • 39
Actiyv
  • 31
  • 1
  • 2

2 Answers2

5

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

Pace
  • 41,875
  • 13
  • 113
  • 156
  • Thanks for the help! Your suggestion did the trick! So this behavior is by design?? Coming from the .NET world I must say I am surprised as it adds a lot of annoyances when debugging. I've never experienced anything like it using Visual Studio. – Actiyv Jul 24 '11 at 15:47
  • I'll agree it's annoying. There is a way, using step filters, to prevent it from happening. Take a look at this question: http://stackoverflow.com/questions/2268902/eclipse-step-into-debugging – Pace Jul 24 '11 at 17:29
0

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

JAB
  • 3,546
  • 9
  • 36
  • 39