Installing Xerces - Windows Troubleshooting

Installing Xerces on a Windows machine can be troublesome, particularly if you've never used Java before. This is an attempt to help you troubleshoot the most likely problems. I assume that you are using the Sun JDK and working from the MS DOS prompt. If you are using an Integrated Development Environment, this may not help. Also, I was using Windows 98 when I developed this guide. I believe that Windows NT and Windows XP use a different method to set environment variables. If you discover errors in this guide, or want to suggest mechanisms troubleshoot other platforms, please send me e-mail.

Try the following steps:

Can you run the Xerces sample programs?
Type:
java dom.Counter [some xml file]
If the program executes, then everything should be set up, and you shouldn't need this guide.
Is Java in you system path?
Type:
java -version
If this outputs a version number and some other information, then your PATH is correct. If this doesn't work, the see Including Java in your path below.
Is Xerces included in your CLASSPATH?
Type:
echo %CLASSPATH%
If the system responds
ECHO is on
then your CLASSPATH is not set. See Setting your CLASSPATH below.

If you see a list of pathnames, make sure that they include paths to the xml-apis.jar file, xercesImpl.jar file, and xercesSamples.jar. For example, my CLASSPATH looks like:

.;C:\Program Files\xerces-2_5_0\xml-apis.jar;C:\Program Files\xerces-2_5_0\xercesImpl.jar;C:\Program Files\xerces-2_5_0\xercesSamples.jar
If you are missing one or more of these JAR files, see Adding JAR files to your CLASSPATH.

Including Java in your PATH

  1. Open up the AUTOEXEC.BAT file using Notepad or another text editor (do not use MS or another word processor as this will screw up your file)
  2. Find the full path of the directory that contains the java.exe file in you JDK install. The last part of this directory is probably /bin. I'm going to refer to this directory as [JAVA_BIN]
  3. If [JAVA_BIN] has not been set in your PATH variable, add the following line at the end of your file:
       SET PATH=%PATH%;"[JAVA_BIN]"
    
    where you type in the directory you found in step 2 for [JAVA_BIN]. Don't forget to surround it in quotes.
  4. Save the file and restart Windows
  5. Open up an MS-DOS window
  6. Type:
       path
    
  7. Check to see if the resulting line contains the [JAVA_BIN] directory. The name may be somewhat abbreviated but should be recognizable. If you can't find it, you've done something wrong. Double-check the previous steps
  8. Go to the directory where you unzipped the annotator
  9. Type:
      java -version
    
  10. You should get information about the version of Java you are using. If not, double-check the previous steps

Setting your CLASSPATH

  1. Find the location where you installed Xerces. This directory should include the files xml-apis.jar, xercesImpl.jar, and xercesSamples.jar. I will refer to this directory as [xerces-home]. Whenever you see that below, type the path name of this directory.
  2. Type:
    SET CLASSPATH=.;[xerces-home]\xml-apis.jar;[xerces-home]\xercesImpl.jar;[xerces-home]\xercesSamples.jar
    
  3. Now try running the Xerces sample program as above.
    java dom.Counter [xml-file]
    
  4. If it doesn't work, check the CLASSPATH again.
  5. If it does work, you might want to add the SET CLASSPATH=... statement to your autoexec.bat file, so that you don't have to type it in everytime you reboot your computer.

Adding JAR files to your CLASSPATH

  1. Find the full path to the missing JAR file. I'll call this [path-to-jar] below.
  2. Type:
    SET CLASSPATH=%CLASSPATH%;[path-to-jar]
    
    You can include multiple files by separating the path names by a semicolon (";").
  3. Now try running the Xerces sample program as above.
    java dom.Counter [xml-file]
    
  4. If it doesn't work, check the CLASSPATH again.
  5. If it does work, you might want to add the SET CLASSPATH=... statement to your autoexec.bat file, so that you don't have to type it in everytime you reboot your computer.