I need an answer for the question in the title.
Thanks.
I need an answer for the question in the title.
Thanks.
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
export CLASSPATH=/your/stuff/
or preserving system wide settings:
export CLASSPATH=$CLASSPATH:/your/addition/
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
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.
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" ...