1

I have similar problem to the one described here: Eclipse and Java - source not found

I also looked at the following question: Eclipse java debugging: source not found but I could not see how that it applied to my case..

I have just started using Eclipse and its debugger. Here is how to reproduce the problem using Eclipse 3.7.2 on Ubuntu 12.04 with java and javac version 7.

  • Start Eclipse and select workspace, e.g., "Test" in home folder.
  • Open java perspective
  • Open new java project with project name "Test"
  • Add a new java class "Test"

I now have the following screenshot:

enter image description here

  • Add the following code to the source file Test.java

enter image description here

  • set a breakpoint at new Test2(1)
  • open debug perspective
  • start debugging:

enter image description here

  • choose Step Into (F5)

Now the error is reported:

enter image description here

Any help on this issue is appreciated..

2
  • Have you tried cleaning the project? (Project->Clean... and select your project)
    – luanjot
    Nov 18, 2013 at 16:26
  • I tried cleaning now, it did not help.. I still get the same error.. Nov 18, 2013 at 16:29

2 Answers 2

2

The class Launcher$AppClassLoader belongs to the JRE and is about to load your class. It has nothing to do with the source code of your own classes. If you step further you will reach your own class Test2. If you go to the end of your debug button bar (four buttons right to the “step into” button), there’s a “Use step filters” button. Activate it to avoid unnecessary steps into the JRE classes.

4
  • Thanks.. it seems you are right. I can step over it and after some more stepping I finally enter the constructor in the Test2 class.. I will try your advice regarding the step filters.. Nov 18, 2013 at 16:41
  • Maybe you have to configure your filters. You can right-click on a stacktrace entry and chose “filter type” or “filter package” to add the particular code to the filter.
    – Holger
    Nov 18, 2013 at 16:56
  • Yes that seems to work.. What if I just open Preferences->Java->Debug->Step Filtering and select all the packages.. Is this adviceable? (I tried it now, and it also seems to work.. but I am not sure if it is the correct approach in general..) Nov 18, 2013 at 17:01
  • 1
    I don’t know what predefined list you have there, but I guess Eclipse will provide useful suggestions. The only thing you have to be aware of is that this list exists. So once you are debugging and need to step in one of these packages you have to either turn filtering temporarily off or switch off that particular package for the debug session, whatever you prefer.
    – Holger
    Nov 18, 2013 at 17:08
0

I believe you have to create an instance of Test before you can access the nested class Test2 in Test. Eclipse should have thrown an error in yours saying something like "No instance of Test2 is accessible" or something like that. Change your code to look like this and see if it works.

public class Test {

/**
 * @param args
 */
public static void main(String[] args) {
    // TODO Auto-generated method stub
        Test mTest = new Test();
        Test2 nTest = mTest.new Test2(1);
}

class Test2{
    int i;

    Test2(int i){
        this.i = i;
    }
}

}

2
  • Test2 isn't a nested class in the OP's screenshot. It's defined outside the scope of Test.
    – matts
    Nov 18, 2013 at 16:39
  • Sorry, my bad...I didnt see the final enclosing braces
    – Rhycce
    Nov 19, 2013 at 2:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.