[ale] OT: Java jar files
Kevin Krumwiede
krum at smyrnacable.net
Sun Jan 27 23:13:15 EST 2002
The classpath is probably one of the most confusing things about Java.
Basically, it is a list of roots where the JVM will look for package trees.
You don't need /usr/java/jdk1.3.1_01 in your classpath unless that's where
you're storing all your non-standard classes (and I wouldn't, because they
don't belong to JDK 1.3.1.) To illustrate, if your classpath is
"/usr/java:$HOME/java:." and your program uses "yourpackage.YourClass", the
JVM will attempt to load "/usr/java/yourpackage/YourClass.class", then
"$HOME/java/yourpackage/YourClass.class", and finally
"./yourpackage/YourClass.class". The JVM will always find its standard
library classes, regardless of whether they are on the classpath.
Anyhow, to get Java to use a jar file as one of its classpath roots, that
jar file must be specified by name in the classpath (e.g.,
CLASSPATH="$CLASSPATH:crimson.jar") both when you compile the program and
when you run it.
Fortunately, java and javac both take a -classpath (or -cp) argument on the
command line, so you can leave your default classpath set to something
general. Note that the command-line classpath is used instead of (not in
addition to) the environment classpath, so you may have to use '-cp
"$CLASSPATH:jarfile.jar"'.
Krum
---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be
sent to listmaster at ale dot org.
More information about the Ale
mailing list