Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CLASSPATH question

 
Frank Hale
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've downloaded a few Java programs that use other class libs. Now I had to add those to my CLASSPATH. The question I have is do I need to explicity add a JAR like this:
SET CLASSPATH=.;c:\jdk1.3\jre\lib\rt.jar;c:\jdk1.3\lib\tools.jar;c:\java\hsql\hsql.jar;f:\jaxp1.0.1\jaxp.jar;f:\jaxp1.0.1\parser.jar;%CLASSPATH%
Or can I just simply tell it what directory those JARS are in? My CLASSPATH is getting huge and I will probably download more Java stuff in the future that calls for adding yet more stuff to my CLASSPATH. This is not a real big issue but something that bugs me.
Keep in mind that everything is working, This is just something I'm concerned about.
Thanks,
Frank
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using Java 2, you can just put the jarfiles in the lib/ext directory and they will be picked up automatically. For Java 1.1, you still have to have a long classpath.
If there are jars which you only use for one or two programs, you can add them to the classpath just before they are used either in a batch file/shell script:
<pre>
set CLASSPATH=mail.jar;activation.jar;%CLASSPATH%
java MyStuff
</pre>
or using the classpath command line parameter
<pre>
java -classpath "mail.jar;activation.jar" MyStuff
</pre>
 
Frank Hale
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have Suns JDK 1.3 so would I put those jars in C:\jdk1.3\lib\ext ? That ext directory doesn't exist, do I just go ahead and create it and put my jars in there?
Thanks,
Frank
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic