Menu

Locale settings ignored by Launch4j executable (maven plugin)

Help
2016-03-15
2016-03-18
  • Jesper Lehtinen

    Jesper Lehtinen - 2016-03-15

    I wrap a Java Swing client with the Launch4j maven plugin (version 1.7.8), and I'm trying to get text fields to use Swedish locale (number formatting, currency). I've noticed that the locale settings seems to be forced to en-US when we use Launch4j. I've confirmed this by running the original .jar with cmd, and a text field displays the number 12345 as "12 345" (Swedish locale). When I run the executable generated by Launch4j, the text field displays "12,345" (English locale).

    I've tried setting <opt>-Duser.language=sv</opt> and <opt>-Duser.country=SE</opt> in <jre> opts, and also specifying locale programatically in a static context in Java, but no luck. Any ideas?

     
  • Grzegorz Kowal

    Grzegorz Kowal - 2016-03-18

    It should be no different when launching the original jar and using launch4j, the only difference I can see is that java is launched by another process but that should not affect the locale. I tried this with Polish local and it's not overwritten. The strange thing is that you say it does not work after setting the locale programatically, I completely cannot see how launch4j could influence that.

    Try to output the user.language, user.country and user.variant properties to see their values upon running the app in order to determine if in fact the locale is wrong or if the problem is only in swing.

    Is the jar exactly the same one as wrapped? Try running java from the command line but instead of the jar use the exe file (java -jar app.exe) and see what happens. This will work as the wrapped app is still a valid jar.

    Grzegorz

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.