I am writing a Java program and I need to set a temporary classpath that includes my package. The package is on my Ubuntu desktop, which I am importing as /home/gaurav/Desktop. Do you have
any idea how to set the Java CLASSPATH temporarily?
I am writing a Java program and I need to set a temporary classpath
Share
You set the Java classpath on Ubuntu the same way as you do on any Linux / UNIX platform (or indeed on Windows … modulo some minor syntactic differences). There are two ways:
or
where
<classpath>is a sequence of pathnames with ‘:’ separators.For more details refer to the manual entry for the ‘java’ command; e.g. here and here.
If you don’t understand
export CLASSPATH=...read the Ubuntu manual entry forbash, paying attention to what it says about setting variables, environment variables, and theexportbuilt-in shell command. (Hint:$ man bash.)This is temporary. To make it permanent, add the line to the relevant shell init script; see
man bashfor details.The classpath is a list of pathnames of directories and JAR files that you want the JVM to search in order to find the classes it needs to run your application. You’ll need to figure that out yourself … or (re-)read the documentation of whatever it is you are trying to run.