FileNotFoundException after exporting as .jar file
filenotfoundexception, jar, java
Solution
When your app is exported as a jar, your config file is not available as a file, since it's wrapped up in the .jar file. Instead you should access it via `ClassLoader.getResourceAsStream()`. See this SO question for more background info.
Problem
I'm using Eclipse and developing a java application where I use of a local file. The file is inside the project folder, in a subfolder, say "mydata/myfile.txt" When I run the app from eclipse everything works fine, I open a FileInputStream passing "mydata/myfile.txt" as the name and the file is read just fine. But when I export my application as .jar, and try to run it, all I get is a FileNotFoundException in the console. How can I export the program so that it can run on any computer and be able to access the file? Thank you in advance.