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
Get Java Garage now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.