I write in Java 7, and test in Windows 7 with Oracle's runtime, and Ubuntu with the open source runtime. This works perfect for those systems:
The path for the parent directory of any running jar file (assuming the class calling this code is a direct child of the jar archive itself):
try {
fooDir = new File(this.getClass().getClassLoader().getResource("").toURI());
} catch (URISyntaxException e) {
//may be sloppy, but don't really need anything here
}
fooDirPath = fooDir.toString(); // converts abstract (absolute) path to a String
So, the path of foo.jar would be:
fooPath = fooDirPath + File.separator + "foo.jar";
Again, this wasn't tested on any Mac or older Windows