Follow me as I struggle with rogue technology, insane programmers, and impossible math questions in a battle to the death.

Friday, May 22, 2009

Using the Java Classpath at the command line

One of the most irritating things about Java is the classpath.

Here's the command on UNIX:

java -cp /Users/jacob/foo.jar:. foo/bar

Here's how to do it on Windows:

java -cp C:\jacob\foo.jar;. foo/bar

The annoying part is that you can't use relative path names. You must put the absolute path for each directory and jar file. Also, on UNIX you separate each path with a semicolon, while on Windows you separate using a semicolon.

Use the -cp flag, then reference you class. Don't append the .class file extension to the name of class, just provide the path relative to where you are executing the Java command.

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home