2

When I try to debug simple java code by stepping over each line, I can debug it successfully. But if I debug it by stepping into each line, I end up getting "Source Not found."

import java.util.*;
    public class LocalClass {
        public static void main(String[] args) {

            System.out.println("Hello ! ");
            Scanner scan = new Scanner(System.in);
            String original = scan.next();
            } 
    }

While debugging, I get the error in line 5 - Scanner scan = new Scanner(System.in); The suspended main Thread information shows "FileNotFoundException"

Note: After surfing through the Eclipse debugging related questions, I edited the source lookup path to point to my source code, but still chances of finding the solution ended in vain.

Can someone explain the reason for this error?

Vikram
  • 2,042
  • 3
  • 14
  • 15

1 Answers1

1

My initial thoughts were that you may not have installed the source code when you installed the JDK - or whatever JRE Eclipse happens to be using.

I knew that I hadn't installed source with my JDK, so I tested the code you included and recreated exactly the same error as you explain.

I managed to fix this for myself by:

  1. Changing the JDK installation to include source (I used the 'Change' option in Add/Remove Programs).

  2. I removed and re-added the JDK in Eclipse (Window > Preferences > Java > Installed JREs) this automatically attached the now included source correctly. I found the easiest way to re-add the JDK was to use search, and navigate to the correct folder (e.g. C:\Program Files\Java\jdk1.7.0_09). Make sure this newly re-added JRE is the selected default for Eclipse to use.

Step 2 may not actually be necessary. I have multiple JREs and got slightly mixed up at one point.

This fixed the problem for me. If it doesn't fix it for you, I would refer you to the (long but not accepted) answer here: Eclipse java debugging: source not found

Community
  • 1
  • 1
MTH
  • 66
  • 7