Reputation: 10641
I need an answer for the question in the title.
Thanks.
Upvotes: 2
Views: 22153
Reputation: 328604
Create a small shell script which sets the classpath:
#!/bin/bash
export JAVA_HOME=...
cp=$(find lib -name "*.jar" -exec printf :{} ';')
if [[ -n "$CLASSPATH" ]]; then
cp="$cp;CLASSPATH"
fi
"$JAVA_HOME/bin/java" -classpath "$cp" ...
Upvotes: 2
Reputation: 308763
I don't think you should have a system classpath environment variable on Linux or any other operating system.
Each and every project should have its own classpath settings. They're usually set by scripts or convention, so there's no need for a system environment variable.
Besides, what would you do if two projects had conflicting JARs required?
Will that environment classpath include every JAR needed by every project on your machine? That's not practical.
A classpath environment variable might have been the standard with Java 1.0, but I don't think it should be now.
Upvotes: 2
Reputation: 134270
If you mean the Java classpath (from your tag), then this is only different from Windows in terms of path-separators (: instead of ;). For example
java -classpath /mydir/mylib.jar:/otherdir/otherlib.jar com.MyProgram -Xmx64m
Upvotes: 3
Reputation: 134601
export CLASSPATH=/your/stuff/
or preserving system wide settings:
export CLASSPATH=$CLASSPATH:/your/addition/
Upvotes: 5
Reputation: 351516
Here are two good tutorials I found via Google:
http://www.linuxheadquarters.com/howto/basic/classpath.shtml
http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/classpath.html
Upvotes: 4