Reputation: 705
I developed a swing java application that connects to Oracle (installed on win).
When it tries to connect to DB get exception as "Locale not recognized".
To solve it, I used environment variable "JAVA_TOOLS_OPTIONS" as bellow.
set JAVA_TOOL_OPTIONS=-Duser.language=en -Duser.region=us -Duser.country=us
and my app works well.
If I want to send my to clients, it would be a problem.
I tried to include settings in my app as adding bellow lines to main class
System.setProperty("user.language", "en");
System.setProperty("user.region", "us");
System.setProperty("user.country", "us");
but doesn't affected and I get exception again.
How can I do that?
Thanks
Upvotes: 1
Views: 936
Reputation: 3487
Maybe this helps: http://www.oracle.com/technetwork/java/javase/envvars-138887.html#gbmsy To me it looks like you cannot set these options using System.setProperty(), because the Java Tool options have to be set before running your application. I would suggest one of these
JAVA_TOOL_OPTIONS="-Duser.language=en -Duser.region=us -Duser.country=us" java -jar [your application]
. I don't know if this would also work for windowsUpvotes: 2
Reputation: 4349
It possible you're not making those calls early enough, and the classes that use them have already been loaded and initialized themselves.
A good test/quick fix would be to make a separate Main class that only makes those calls, then calls the class you are currently using to start your app.
You might even have to call those in a static initializer (not in main), because once you execute main, all the classes it references will be loaded first.
You could also use reflection to load and execute your class from Main, that's kind of messy and probably not required.
Upvotes: 1