2

Currently I am trying to simply step through my program in the debugger via 'f5'. However, each time I am met with "Source not found", & the debugger quits out despite the program actually running fine.

There are several other questions with similar problems. I tried those solutions - in particular the one found here. However, still no luck after attempting to add the "source" via the "source-lookup" option in the debug menu.

Here is the code:

package com.xmlParsing;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class DomParsingMain {

public static void main(String[] args) {
    
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    
    try {
        DocumentBuilder db = dbf.newDocumentBuilder();
        
        Document doc = db.parse("DictionaryPractice.xml");
        
        NodeList nl = doc.getElementsByTagName("definableterms");
        
        
        for(int i = 0; i < nl.getLength(); i++) {
            
            Node p = nl.item(i);
            
            if(p.getNodeType() == Node.ELEMENT_NODE ) {
                
                Element contents = (Element) p;
                String attribute = contents.getAttribute("Introduction");
                System.out.println(attribute);
                
            }
            
        }
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

}

And here is the screen that I get post 'f5' press:

enter image description here

Thanks for any help

Community
  • 1
  • 1
Matthew
  • 817
  • 1
  • 13
  • 39
  • Did you install jdk? – Nicholas K Oct 16 '18 at 16:57
  • Yes, I can debug other programs fine EDIT - maybe I didn't, I'm not sure. Would my programs even run without it? My other programs run as they should. – Matthew Oct 16 '18 at 16:57
  • Programs in eclipse will run because it has an inbuilt compiler. Does the jar you downloaded have the source code? – Nicholas K Oct 16 '18 at 17:30
  • @Matthew as I can see in your print, you are using jre1.8.0_181. If i'm not wrong, you don't have the source of your .classses. You should download jdk, inside the jdk instalation folder, you have a src.zip. Inside this src you have the source of some of these org.w3c. Unzip it then go to Eclipse, find "Debug Configurations", then click on the tab "Source" > "Add" > now you have to select your folder with sources. Try it and see if it works. – jhenrique Oct 16 '18 at 17:43

1 Answers1

3

Download jdk, and repeat this attempt here. If it still doesn't work, take a look at my prints, go to your jdk folder, find the src.zip

.java location

Then you unzip the src and you'll have all .java you'll need. Node.java is just an example of a class that you are using in your program.

src

Now you will have all sources and it will help you also with other sources you may need. It is also a good way to learn some great code.

jhenrique
  • 858
  • 1
  • 10
  • 17