Ed's Big Plans

Computing for Science and Awesome

Archive for the ‘PAL’ tag

Java Classpaths are Evil

with 2 comments

(now also in from my wiki)

While working with Phylogenetic Analysis Library (PAL) for an alignment problem, I ran into the problem of having to specify classpaths to a jar file… it should have be straight forward enough…

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.

A side effect of not being able to put spaces in between the colons of several paths is that one can’t just put a backslash in to negate a newline– you would need to have the next path start at the very beginning of the next line which is just ugly.

Eddie Ma

November 23rd, 2009 at 12:28 pm

Posted in Pure Programming

Tagged with ,