Note that I am talking about Java 7, since the info.plist specification for a Java .app bundle seems to have changed a bit since Java 6.
Currently my code looks like this:
File file = new File( "documentation/index.html" );
if (file.exists()) {
// opens the URI in the browser
GUIUtils.openURI( file.toURI() );
} else {
// opens the URI in the browser
GUIUtils.openURI( getClass().getResource( "/documentation/index.html" ).toURI() );
}
In the Java
subfolder in the app bundle, I have a "documentation" subfolder. I have tried multiple things, to no avail:
-Duser.dir
JVMArgument property) - the file seemingly has the right path, but file.exists()
returns false.getClass().getResource()
still returns null)If you're prepared to use the com.apple
extensions, com.apple.eio.FileManager.getPathToApplicationBundle()
will give you the base path to your bundle, and you can then create a File
relative to that.