I am trying to configure the classpath of a JAR so that my ResourceBundle can pick up property files from it.
If I run it from the .class files and specify the -cp flag it works fine, and System.err.println(System.getProperty("java.class.path")); will print the path specified in the -cp flag.
If I try and create a jar file for it, System.err.println(System.getProperty("java.class.path")); always prints the path of the jar file, and the property files aren’t picked up.
It seems if you are running it as a jar file you can’t specify the -cp flag (which was what I was hoping, as it’s common to switch which property files are being used). I’ve tried specifying it in the jar manifest instead, but it’s still not working.
Here is the code and manifest from a test jar that doesn’t seem to work:
public final class Test {
public static void main(final String[] args) {
System.err.println(System.getProperty("java.class.path"));
}
}
Manifest-Version: 1.0
Created-By: 1.6.0_20 (Sun Microsystems Inc.)
Main-Class: Test
Class-Path: /home/ajanuary/Projects/test/
edit
The original path was rather meaningless so I changed it. I want to point to a directory which the ResourceBundle can find the property files in.
The problem was that I also had an index file. If you have an index file, the Class-Path will be ignored.