Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / February 2005

Tip: Looking for answers? Try searching our database.

CLASSPATH question

Thread view: 
john smith - 26 Feb 2005 01:02 GMT
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 - 26 Feb 2005 04:20 GMT
> If I have *.JAR files in the same directory that I am compiling
> my java code do I have to include a classpath.
[quoted text clipped - 14 lines]
> 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/tutorial/ext/basics/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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.