Application bundle on OS X does not work, file addressing problem
My application requires a XML file to work and it doesn't even start with开发者_开发问答out the file. Why I bundle my app as a JAR file it works fine as long as the XML file is placed in the same directory as the JAR file.
When I'm exporting the project as an OS X application package, the application does not work. If I copy the XML file in the same directory where the application package is, it works.
So I'm pretty sure that it is a minor addressing problem to access the XML file from within my Java code. I'd like to put the XML file into the application package. Simply copying it in the same directory where the JAR file is does not work.
The file, or better the files are addressed like this: doc = sax.build("file.xml");
and are located directly in my project folder.
I'm working with Eclipse and I export my project directly from Eclipse as an application bundle.
I also tried it with the OS X Jar Bundler, which delivers the same result.
So, how do I address my files correctly, so that I can place them into the application bundle?
Any help is appreciated! Thank you very much!
You are most likely reading it in as a physical file, which needs to be located in the current working directory.
Have you considered reading it in as a resource instead which allows it to be found via the classpath?
精彩评论