This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Including a jar file in your classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Including a jar file in your classpath" Watch "Including a jar file in your classpath" New topic

Including a jar file in your classpath

Steve Jensen
Ranch Hand

Joined: Sep 23, 2002
Posts: 126
Really silly question folks, sorry about this.
How do I include a jar file in my classpath?
I'm using a PC running Windows 98 (second edition).

John Bonham was stronger, but Keith Moon was faster.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
You would probably need to do that in your C:\AUTOEXEC.BAT file and then reboot the machine.
The %CLASSPATH% tells the system to put the "old" or "previous" value of the CLASSPATH at the end of the new CLASSPATH. If there was no previous CLASSPATH you can use SET CLASSPATH=C:\ADIRECTORY\ajarfile.jar;.
Note the semicolon and period at the end!

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Steve,
You can just drop a copy of the jar in your jre/lib/ext directory or you can append the fully qualified name to your CLASSPATH envrionment variable (eg C:\MyJars\MyClasses.jar) or you can build a classpath on most of the java utilities (like javac, java, etc.) with a -classpath flag like this:
javac -classpath .;C:\MyJars\MyClasses.jar
Hope this helps,
Michael Morris

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
I agree. Here's the link:
subject: Including a jar file in your classpath
jQuery in Action, 3rd edition