Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Xerces 2.5.0 Classpath problems

Status
Not open for further replies.

bateman23

Programmer
Mar 2, 2001
145
DE
Hi,

i'm running JDK 1.4.1 and tried to use the latest Apache Xerces Package. I downloaded everything and extracted the files to "D:\Development\xerces-2_5_0\".
In my book it's said you have to add the xerces.jar file to the classpath. Ok, i know this file doesn't exist any more in Version 2.5.0. The install.html gives hints and says to add the two files xercesImpl.jar and xml-apis.jar instead.
So i did. But still trying to use "import org.apache.xerces.parsers.DOMParser;" just gives me the error message:
"W3DomTest.java:17: package org.apache.xerces.parsers does not exist"

What's wrong ?
Thanx in advances,
Daniel

---------------------------------------
Visit me @:
 
A few things to check :

- Are there any conflicting or older packages/classes on the CLASSPATH ?
- Are your jar files really on the CLASSPATH (chuck them in /jre/lib/ext and they will be picked up automatically)
- Open the jar files with something like WinZip or the "jar" tool, and check that the classes/packages you are trying to import/reference are actually in the jar file.
 
Hi sedj, thanx so far.
Afaik there are no conflicts. Here is my whole Classapth:

D:\Development\JDOM\jdom-b9\build\jdom.jar;
D:\Development\xerces2_5_0\xercesImpl.jar;
D:\Development\xerces2_5_0\xml-apis.jar;
D:\Development\xerces2_5_0\xercesSamples.jar;
.;
D:\JBuilder8\jdk1.4\bin;E:\XML-Test

I copied the files above to /jre/lib/ext but that also didn't work.
Anyway: I'm trying to import that stuff through:

import org.apache.parsers.DOMParser;

But how does Java know where to look for the org packages ?
Somehow i'm a little confused...
For example i found another jdom.jar (that package works fine) in the lib-Pah of JBuilder8 (which i've also installed, but don't use at the moment). So i copied the Xerces Files into that directory. Didn't work...
Perhaps i have to rename the paths somehow ?

---------------------------------------
Visit me @:
 
Java knows where the "org" packages are, becasue it takes the directory of the jar file, and then makes sure that each sub-dir within the jar contains what is in the "import" statement - so an import of a package "com.acme.test.*" would need to reflect in a jar file as a directory structure as
Code:
 com
        |--
           acme
             |
              --
                test
if you see what I mean ...

- Have you checked the files are in the jar files (Open the jar files with something like WinZip or the "jar" tool, and check that the classes/packages you are trying to import/reference are actually in the jar file.)

- Make sure that no classes clash between your xerces ajrs and your jdom.jar.

- Are you sure that the classpath is defined as "CLASSPATH" (ie upper case). Type "set CLASSPATH" in your console to check the path again ....

- Failing that, as a stop-gap, unzip all the jar files into a directory and try it from there using a
Code:
javac -classpath . Test
, making sure that your Test.class file is in directory "." - with the org/* packages underneath.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top