Setting your Java CLASSPATH variable
If you want to use Java classes other than the standard Java library classes (like Scanner) and the classes that are in your current directory, you need to set your Java CLASSPATH variable.
Suppose you had created a class named "Canvas" and that you wanted to use it in serveral projects. You may want to put Canvas.class (and all your other shared classes) in a separate directory. Start by creating a directory for your shared classes. Open a unix terminal window and create the directory:
Engelbart> mkdir ~/myclasses
To tell Java where to find the file Canvas.class, you need to set your CLASSPATH variable in a file in your home directory called ".cshrc". Edit ~/.cshrc:
Engelbart> nedit ~/.cshrc &
Then add the following line to the bottom of the file:
setenv CLASSPATH ~/myclasses:.
Note the . at the very end. This tells Java to look in the current directory for class files as well.
Now save ~/.cshrc and either close all your open terminal windows and reopen them or type the following in all the terminal windows in which you need the CLASSPATH set:
Engelbart> source ~/.cshrc
To see whether the CLASSPATH was set properly, in a terminal window, you can type:
Engelbart> echo $CLASSPATH
Note: The echo will replace the "~" with the whole path to your home directory.
- CS Mini Courses
- go.carleton.edu/lynda
- Installing Python On Your Home Computer
- PIL (Python Imaging Library) for Python 2.x
- Installing Java on your home computer
- Setting your Java CLASSPATH variable
- Java Documentation
- Scanner class
- TeX and LaTeX
- Running programs in the background
- Compiling in Linux
- Beep Program
- Makefiles
- Keyboard Interrupts
- Installing Cygwin







