Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java SE Maven project using ResourceBundle for internationalization

I'm working on a Swing application that has to be localized.

For that purpose, I'm using a resourceBundle. It works fine when I run the application from the IDE. But when I use maven to generate the jar, the application starts up normally but the internationalization stops working. Without throwing any exception, I have make a lot of variations to solve that problem; I even have make a class that inherits from java.util.ResourceBundle.Control. The only thing I've achieved to make it work is by placing the properties files outside the package (I place it into the desktop just for testing). I then try to use the same method by specifying the path by new File(".").getAbsolutePath().

Doing that still keeps working from running it from Eclipse, but when I try to generate the jar and execute it, it throws an exception and the application does not start.

like image 640
wiggin200 Avatar asked Aug 04 '26 17:08

wiggin200


1 Answers

If you place your properties file into src/main/java next to the Java code, Maven will probably not pick it up.

The canonical location would be src/main/resources (with the package structure below that duplicated just as it is now in your code).

like image 120
Thilo Avatar answered Aug 06 '26 06:08

Thilo