File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Classpath setting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Classpath setting" Watch "Classpath setting" New topic

Classpath setting

Ajit Deshpande2

Joined: Nov 27, 2000
Posts: 9
I have a problem setting classpath. I have set up the basic java compiler correctly. I have a problem whenever I have to add jar files like XML parsers, etc. These add-ons have a number of jar files. Do I have to add extra jar files to the classpath variable? THis makes the classpath too big and unmanageable. Is there a way to just drop the jar files, and the automatically come in the classpath?
Christopher Dixon

Joined: Jan 30, 2002
Posts: 22
Yes. You can place the .jar files in the /lib/ext directory of the JRE, ie c:\jdk1.4\jre\lib\ext. There are a couple of caveats to this, though:
  • Some compilers may not pick up the .jar files. If this is the case and you have a bunch of .jar files, look into scripting or using a build tool like ant
  • The files you place into this directory will load with higher permissions than files loaded by a delegated classloader.
  • If you're using an application container (like Tomcat, JBoss, Websphere, etc),some .jar files (Struts is first to come to mind) must be loaded for each web application seperately. They should not be placed in /jre/lib/ext. They would normally say this in the documentation.

  • If you're interested in why, check out:
    How the classloader works
    [ October 27, 2002: Message edited by: Christopher Dixon ]
    [ October 27, 2002: Message edited by: Christopher Dixon ]
    I agree. Here's the link:
    subject: Classpath setting
    It's not a secret anymore!