java - FileNotFound exception, when files are in /Applications/Foobar.app on a Mac -
summary - code:
file f = new file("dbfile.dat"); f.getabsolutepath();
returns:
/applications/dbfile.dat
the problem application's resources (3d party jars instance) located in "applications/foobar.app/...".
how path install folder without hardcoding anything?
details:
i'm using 3d party library need provide filename:
ls = new lookupservice("dbfile.dat");
when distributed, file placed in root of install folder, next executable files - works great on windows.
however, on mac fnf exception because library isn't searching in correct location:
java.io.filenotfoundexception: dbfile.dat (the system cannot find file specified) @ java.io.randomaccessfile.open(native method) @ java.io.randomaccessfile.<init>(unknown source) ...
try this:
url myclass = myclass.class.getresource("myclass.class"); system.out.println(myclass.getpath());
this print out this:
file:/home/mike/test.jar!/myclass.class
you can parse out need that.
Comments
Post a Comment