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?
posted 13 years ago
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 HTH, Chris [ October 27, 2002: Message edited by: Christopher Dixon ] [ October 27, 2002: Message edited by: Christopher Dixon ]