Reputation: 75
So i have wrote an application that uses 'config.properties' & 'profile.properties' Files.
Anything works fine in Eclipse (Debug), but after exporting Runnable JAR , this JAR does not include the Properties Files. so i dragged this two files inside the jar and now i got this exception / error:
java.io.FileNotFoundException: config.properties (Nie można odnaleźć
określonego pliku)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at com.profilemaker.Profiler.<init>(Profiler.java:32)
at com.main.Main.main(Main.java:7) Exception in thread "main" java.lang.NullPointerException
at com.profilemaker.Profiler.<init>(Profiler.java:43)
at com.main.Main.main(Main.java:7)
Upvotes: 2
Views: 60
Reputation: 31
@JB Nizet answer is correct. Also make sure that /path/in/the/jar/of/the.properties is added to the classpath when running the application
Upvotes: 2
Reputation: 691715
If the properties are in the jar, you shouldn't be using a FileInputStream to read them. Entries of a jar file are not files. A file lives on your file system. Not in a jar.
Use
Profiler.class.getResourceAsStream("/path/in/the/jar/of/the.properties")
to read the properties resources.
Upvotes: 3