Eclipse won't resolve org.apache.* packages
843789May 13 2010 — edited May 13 2010Hello everyone,
I'm relatively new to java and eclipse and I am really stuck trying to use various packages.
First a little history on what I am doing. I've created a project from existing source using the new java project wizard. This source code is obtained from the Book: XML and Java: Developing Web Applications, 2nd Edition. It's sort of dated. It uses SDK 1.3, and xerces 1.4.3 the current is 2.9.1. I have version 2.9.0 according to the Eclipse plugin registry. ( Thought I'd mention this in the event it may be relevant ).
The problem is Eclipse will not resolve this line of code:
import org.apache.xerces.parsers.DOMParser;
I look at plugins and I see xerces listed:
Provider:: eclipse.org
Plug-in Name:: Apache Xerces-J
Version:: 2.9.0v200909240008
Plug-in ID:: org.appache.xerces
However, Eclipse content assist does not list any org.apache packages and of course it won't compile without fatal errors.
In an attempt to correct the problem I've created a classpath variable in
Preferences > Java > Buildpath > Classpath variables:: xerces_2_9_0 - /Applicatins/Eclipse/plugins/org.apache.xerces_2.9.0.v200909240008.jar
Then added the var to a launch configuration.
The same error still persists::
_____________
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
DOMParser cannot be resolved to a type
DOMParser cannot be resolved to a type
at chap02.SimpleParse.main(SimpleParse.java:20)
_____________
I've also tried to add jar's to the libraries using Preferences > Java > Build Path > User Libraries but the the button on the right 'Add jars...' is not acitve.
The complete source code is listed below. Although I don't think the problem resides there.
Anyone who can help me in understanding this problem and resolving it would be greatly appreciated.
( I obviously am misunderstanding something ).
Regards,
gjames
package chap02;
/**
* SimpleParse.java
**/
import org.w3c.dom.Document;
import org.apache.xerces.parsers.DOMParser;
import org.xml.sax.SAXException;
import java.io.IOException;
public class SimpleParse {
public static void main(String[] argv) {
if (argv.length != 1) {
System.err.println(
"Usage: java chap02.SimpleParse <filename>");
System.exit(1);
}
try {
// Creates a parser object
DOMParser parser = new DOMParser();
// Parses an XML Document
parser.parse(argv[0]);
// Gets a Document object
Document doc = parser.getDocument();
// Does something
} catch (SAXException se) {
System.out.println("Parser error found: "
+se.getMessage());
System.exit(1);
} catch (IOException ioe) {
System.out.println("IO error found: "
+ ioe.getMessage());
System.exit(1);
}
}
}