O'Reilly logo

Java Garage by Eben Hewitt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Setting the Classpath at Compile Time

You can set the classpath at compile time. This is useful if you have a quick class you want to try out, and it relies on a library or other class that is not currently on your classpath. You do so using the -cp flag. You can also use -classpath if you are exceptionally fond of typing.

Try it like this:

javac -cp C:\\garage\classes SomeClass.java

Note that you can combine flags as well:

javac -source 1.5 -cp
     /user/eben/garage/SomeClass.java

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required