?
Solved

CLASSPATH Issues

Posted on 2003-10-23
8
Medium Priority
?
332 Views
Last Modified: 2013-11-23
Hello
I'm fairly new to Java, and as a result I'm having major problems getting my packages to be recognized when I compile the programs.

I'm trying to install a sax parser (I downloaded it from a link from the http://www.saxproject.org website)

The file is sax2r2.jar
and is located at C:\j2sdk1.4.2_02\sax2r2.jar

When I installed xerces, it said to do a jar -xf <file> to install it, so I did the same with this sax file
c:\j2sdk1.4.2_02> jar -xf sax2r2.jar

Which creates the following directory:
C:\j2sdk1.4.2_02\sax2.0.1\

Which in turn has sax.jar
C:\j2sdk1.4.2_02\sax2.0.1\sax.jar

and to subfolders apidoc and src

within C:\j2sdk1.4.2_02\sax2.0.1\src\ there is a subfolder org
C:\j2sdk1.4.2_02\sax2.0.1\src\org\xml\sax

Here is my CLASSPATH variable specified in the User section of the Environment Variables section of the System configuration option in Windows XP Professional (Up to date with all patches/service packs if that matters).

Here is my CLASSPATH variable
.;c:\j2sdk1.4.2_02\dom4j-1.4\dom4j.jar;C:\j2sdk1.4.2_02\xerces-2_5_0\xml-apis.jar;C:\j2sdk1.4.2_02\xerces-2_5_0\xercesImpl.jar;C:\j2sdk1.4.2_02\xerces-2_5_0\xercesSamples.jar;C:\j2sdk1.4.2_02\sax2.0.1\sax.jar;C:\j2sdk1.4.2_02\sax2.0.1\src\

Here is my PATH variable
C:\jwsdp-1.2\jwsdp-shared\bin;C:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT;C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program Files\Microsoft Visual Studio\Common\Tools;C:\Program Files\Microsoft Visual Studio\VC98\bin;C:\j2sdk1.4.2_02\bin;


when I'm attempting to javac my program, c:\VectorProject\Parse.java:
--------------------------------------------------------------------------------------------------------------------------------------------
/*
 * Parse.java
 *
 * Created on October 20, 2003, 1:04 PM
 */

/**
 *
 * @author  Shoeman22
 */
import java.net.URL;
import java.util.*;
//import org.w3c.dom.Document;
import javax.naming.*;
import javax.xml.parsers;
import org.xml.*;
import java.io.*;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.io.SAXReader;

public class Parse {
    String url;
    Vector myVector;
    Document document;
    /** Creates a new instance of Parse */
    public Parse(String u) {
        url = u;
        myVector = new Vector();
        document = this.returnXML();
    }
   
    private Document returnXML() throws DocumentException {
        SAXReader reader = new SAXReader();
        Document document = reader.read(url);
        return document;
    }
   
    public void process() {
        List list = document.selectNodes( "//svg/line" );

        for (Iterator iter = list.iterator(); iter.hasNext(); ) {
            Attribute attribute = (Attribute) iter.next();
            String url = attribute.getValue();
        }

    }
}
-------------------------------------------------------------------------------------------------------------
when I run, from the command prompt, c:\VectorProject > javac Parse.java
I get the following errors:
-------------------------------------------------------------------------------------------------------------
Parse.java:15 package javax.xml does not exist
import javax.xml.parsers;
                        ^
Parse.java:16: package org.xml does not exist
import org.xml.sax;
                     ^
Parse.java:44: cannot resolve symbol
symbol : class Attribute
location: class Parse
                  Attribute attribute = <Attribute> iter.next();
                  ^

Parse.java:44: cannot resolve symbol
symbol : class Attribute
location: class Parse
                    Attribute attribute = <Attribute> iter.next();
                    ^

4 errors
---------------------------------------------------------------------
I assume this is a real easy fix, but I've been tearing my hair out trying to get this to work for the past couple of days, so any assistance would be greatly appreciated.

If you could just specify what exactly I should have for my CLASSPATH and PATH variables I'd really appreciate it.  I did do a search here prior to posting this and saw a thread stating the the CLASSPATH is basically a root directory for your import statements to append to...hence why I assumed my CLASSPATH entry: C:\j2sdk1.4.2_02\sax2.0.1\sax.jar;C:\j2sdk1.4.2_02\sax2.0.1\src\ would work correctly.

Thanks for the help,
Shoeman22
0
Comment
Question by:shoeman22
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 3

Expert Comment

by:savalou
ID: 9608570
Should probably be:

import javax.xml.parsers.*;
import javax.xml.sax.*;
0
 
LVL 3

Accepted Solution

by:
savalou earned 200 total points
ID: 9608583
Sorry,

import org.xml.sax.*;
0
 

Author Comment

by:shoeman22
ID: 9609382
savalou
Thank you, that cleared up the first 2 errors involving the importing, but I'm still getting the bottom 2 errors resulting from the Attribute class not being found...

What else do I need to import/install in order to eliminate the Attribute symbol not resolved error?
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 3

Expert Comment

by:savalou
ID: 9610026
ummm...is Attribute a dom4j class?  I'm guessing then you need an

import org.dom4j.Attribute;

0
 

Author Comment

by:shoeman22
ID: 9610209
I did this and it worked.

so I changed my import list to:
import java.net.URL;
import java.util.*;
//import org.w3c.dom.Document;
//import javax.naming.*;
//import javax.xml.parsers.*;
//import org.xml.sax.*;
import java.io.*;
//import org.dom4j.Document;
//import org.dom4j.DocumentException;
//import org.dom4j.io.SAXReader;
import org.dom4j.io.*;
import org.dom4j.*;

Thanks for the help...one other thing...when I compiled the program, it gave me 26 warnings regarding deprecation relating to dom4j and sax, but it still compiled...is that a something to be concerned about?

Thanks
0
 
LVL 3

Expert Comment

by:savalou
ID: 9610358
>> when I compiled the program, it gave me 26 warnings regarding deprecation relating to dom4j and sax, but it still compiled...is that a something to be concerned about?

Not for the moment, if everything works...some deprecated Java SDK methods throw an IllegalArgumentException or something if try to use them (java.util.Date does/did that a lot).  You should probably look at the javadoc of the deprecated methods to find out why they are deprecated and what to do about it.

But, nah, live dangerously!
0
 

Author Comment

by:shoeman22
ID: 9610688
Good to know,
Thank you very much for your help savalou!
I already accepted your answer, but while I've got your attention...

Do you know how to make Netbeans recognize my imports as valid packages?

Also, I just went to java.sun.com and found NetBeans...are there better programs for development, or is Netbeans the preferred?

Thanks again,
Shoeman22
0
 
LVL 3

Expert Comment

by:savalou
ID: 9611118
Well, you've got my attention as long as this thing keeps e-mailing me...

Personally, I use NetBeans myself and I like it.  I've also had colleagues tell me Eclipse is good, I've never tried it much.  These two are free, so what's not to like?  

I don't know what you mean by "make Netbeans recognize my imports as valid packages".  If you mean that it complains about
import org.xml.sax.*;
when you try to compile your code, that's because you have to mount sax.jar in the FileSystem (right-click on filesystem, click on mount, ...).  

Alright?  Any more questions, buddy, and you'll have to pay me mucho dinero!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to implement Singleton Design Pattern in Java.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month9 days, 17 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question