Reputation: 2065
I am encountering an issue when trying to load a resource.
java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("Bundle");
My file is correctly named Bundle_en_US.properties
in the src
folder.
While I am aware of this solution (and many others), my case is different because my Java program runs fine from Eclipse but the error below is triggered when ran from an executable jar file.
Exception in thread "AWT-EventQueue-0" java.util.MissingResourceException: Can't find bundle for base name Bundle, locale en_US
at java.util.ResourceBundle.throwMissingResourceException(Unknown Source)
at java.util.ResourceBundle.getBundleImpl(Unknown Source)
at java.util.ResourceBundle.getBundle(Unknown Source)
I am using: Windows 10, Eclipse Photon, JDK 8 and JDK 10, JRE 8 and JRE 10
And I can see all my *.properties files in the jar file when opening with an archive manager :
Upvotes: 0
Views: 2265
Reputation: 2065
I just found the solution to my own issue. The reason was that in the .classpath
file, only the .java files were outputted. Hence, my properties files were outputted in a different directory and were not found by the resourceLoader.
Original .classpath entry :
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src">
Resolved by modifying the line entry to :
<classpathentry kind="src" output="target/classes" path="src">
Upvotes: 1