Setting the Classpath in Java


This page is obsolete.


To use our standard library files (StdDraw.java, StdIn.java, and StdOut.java), you can place them in the same directory as the main program you are writing. A drawback with this is approach is that you end up with many copies of the same library files, scattered in different directories. Java's classpath mechanism allows you to store and access the library files from a common directory.

Organizing the Shared Libraries

Place the shared library files (StdDraw.java, StdIn.java, and StdOut.java) in a commond directory, say C:\introcs. Go to that directory and compile them.

Setting the Classpath in DrJava

To set the classpath for DrJava:

Setting the Classpath for the Windows Command Prompt

To set the classpath for the Windows XP Command Prompt:

Setting the Classpath in OS X

To set the classpath for the bash shell in OS X:

Troubleshooting

Here are a few suggestions that might help correct any installation woes you are experiencing. If you need assistance, don't hesitate to contact a staff member.

How can I check the value of my CLASSPATH variable?