I am working with java and I am trying to parse an xml document. The code works in eclipse but when I try to run it on the terminal I get this error. java.lang.ClassNotFoundException: org.jdom2.Document I am using the org.jdom2.Document as a data type which might be the problem. I don't know what can be used in place of it.
public class ReadXMLFile
{
public static org.jdom2.Document Read()
{
String fileName = "test_file.xml";
org.jdom2.Document jdomDoc = new org.jdom2.Document();
try
{
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(new File(fileName));
DOMBuilder domBuilder = new DOMBuilder();
jdomDoc = domBuilder.build(doc);
}
catch (Exception e)
{
}
return jdomDoc;
}
}
My code example.