Specifying Classpaths

Java is great. Really. But there are sometimes subtleties that need to be kept in mind as I had to find out in the last few days once more. After looking in all the wrong places, that is. I’m talking about specifying a classpath. Multiple entries on the classpath are delimited by a separator but that separator is not always the same:

  • JVM Classpath on Windows (semicolon): “-cp my1.jar;my2.jar”
  • JVM Classpath on Unix (colon): “-cp my1.jar:my2.jar”
  • Class-Path entry in a JAR manifest (space): “Class-Path: my1.jar my2.jar”
  • OSGi’s Bundle-Classpath entry in a bundle manifest (comma): “Bundle-Classpath: .,META-INF/lib/my1.jar,META-INF/lib/my2.jar”

I’m sure someone will eventually come up with yet another separator for classpath entries.

Veröffentlicht unter Java