Home > Archive > Java Help > February 2005 > CLASSPATH question
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
CLASSPATH question
|
|
| john smith 2005-02-26, 3:59 am |
| If I have *.JAR files in the same directory that I am compiling my java code
do I have to include a classpath.
will the JAVA compiler go to the *JAR files in the current directory to find
the org.apache and orl.xml.sax as noted in the
code below?
The reason I ask the question, I put some *.JAR files in my class path that
really messed something up because
I could no longer run my java programs. My java programs would compile, but
they would not run. It was if
the computer had trouble locating the *.class file. I ended up having to
reinstall the JAVA distribution then everything was ok again.
Yes it was just really strange.
So, I thought I would just forget about the class path and put the *JAR
files in the path I am compiling. But I'm not sure if this is correct.
Please help. Thanks
package sax;
import org.apache.*;
import org.xml.sax.*;
public class ParseDoc {
public static void main( String[] args) throws Exception {
XMLReader reader = new SAXParser();
reader.setContentHandler( new Handler() );
reader.parse("mydata.xml");
}
}
class Handler implements ContentHandler {
public void setDocumentLocator( Locator locator) {}
public void startDocument()
{
System.out.print("Start");
}
public void endDocument() {}
public void startElement(String namespace, String name, String qName,
Attributes atts){}
public void endElement(String namespace, String name, String qName) {}
public void characters( char[] ch, int start, int length) {}
public void processingInstruction( String target, String data){}
public void startPrefixMapping(String prefix, String uri ){}
public void endPrefixMapping( String prefix) {}
public void ignorableWhitespace( char[] ch, int start, int length ) {}
public void skippedEntity(String name ) {}
}
| |
| Anthony Borla 2005-02-26, 3:59 am |
|
"john smith" <princetonharvard@charter.net> wrote in message
news:KYPTd.10304$W%5.3312@fe02.lga...
>
> If I have *.JAR files in the same directory that I am compiling
> my java code do I have to include a classpath.
>
> will the JAVA compiler go to the *JAR files in the current
> directory to find the org.apache and orl.xml.sax as noted
> in the code below?
>
> The reason I ask the question, I put some *.JAR files in
> my class path that really messed something up because
> I could no longer run my java programs. My java programs
> would compile, but they would not run. It was if the computer
> had trouble locating the *.class file. I ended up having to
> reinstall the JAVA distribution then everything was ok again.
> Yes it was just really strange.
>
> So, I thought I would just forget about the class path and put
> the *JAR files in the path I am compiling. But I'm not sure if
> this is correct.
>
May I suggest that you read through here:
http://java.sun.com/docs/books/tutorial/ext/index.html
in particular, this section:
http://java.sun.com/docs/books/tuto...cs/install.html
which contrasts two approaches to this problem.
You should find that you may never need to 'mess with' CLASSPATH again :) !
I hope this helps.
Anthony Borla
|
|
|
|
|