Java Classpath Hints
From SnOwy - Ed's Wiki Notebook
Java classpaths are a pain.
Here are a few observations I've made about how to specify them in the command line.
- an Item can either be a directory that contains .class and .java files OR
- an Item can be a .jar file.
- to specify more than one Item.jar in Unix, use:
javac -classpath .:Item1.jar:Item2.jar
- note that you cannot put a space between the colons
- note that you must include an extra Item '.' to specify the current working directory
- note that in Windows, you must use ';' instead of ':'
- note that after compiling with javac, the same -classpath and its arguments must then be applied with java
Nuisance? Yes! Necessary Evil? No!
In the compiled Java class, there certainly could have been some metadata implemented that is a copy of the last known classpath string... why is there a disparity between the symbols used in Unix and Windows? ... Why aren't spaces allowed? Why does one have to specify the current working directory?
Evil.