Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Changing locale in JVM?(Locale won't change despite altering it in JVM)
Changing locale in JVM? [message #1797073] Wed, 24 October 2018 19:49 Go to next message
Reinhardt Christiansen is currently offline Reinhardt ChristiansenFriend
Messages: 73
Registered: March 2010
Member
I am trying to test some Java classes I have written in Eclipse via JUnit 5. Some of my tests involve changing my locale from the default on my machine, en-CA, to another one. (I want to use de-DE because I have some German language ability.)

I've added the following to the VM arguments of the run configuration for the JUnit test case:
-Duser.language=de-DE

Just for the heck of it, I display the value of the current month name directly within the method I am testing. When I run the test though, I get "October", the English spelling, instead of "Oktober", the German spelling.

I tried adding the same argument to the VM arguments of the run configuration for the class itself but "October" still gets displayed. Clearly, my arguments are being ignored. I found several items in StackExchange that say this approach should work but they all referred to older versions of Java and Eclipse.

Has the approach changed for my current setup, Java 10.0.2 and Eclipse 2018-19 on Windows 10? If so, how do I do it now?

I noticed that when I click the Variables buttons in the run configurations that a bunch of different variable names appear but NONE of them look like -Duser.language or whatever - and none of them refer to locales.
Re: Changing locale in JVM? [message #1797098 is a reply to message #1797073] Thu, 25 October 2018 08:37 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
I think you need to use -nl for this purpose:
https://help.eclipse.org/oxygen/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fruntime-options.html
Note that this is a program argument, not a VM argument.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Changing locale in JVM? [message #1797124 is a reply to message #1797098] Thu, 25 October 2018 18:20 Go to previous messageGo to next message
Reinhardt Christiansen is currently offline Reinhardt ChristiansenFriend
Messages: 73
Registered: March 2010
Member
Thanks for getting me going in the right direction, Ed! Much appreciated, especially the fact that these are program parameters NOT VM parameters.

Do you have any idea what syntax the -nl parameter expects? I don't see any examples in the documentation. I could try a lot of different things before I stumble on the right syntax by trial and error....
Re: Changing locale in JVM? [message #1797140 is a reply to message #1797124] Fri, 26 October 2018 06:38 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Note that one way of answering such a question is to launch a runtime application and to look at the Properties of the launched process. E.g., I can see this in those properties:
-nl en_US


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Changing locale in JVM? [message #1797196 is a reply to message #1797140] Sat, 27 October 2018 15:43 Go to previous message
Reinhardt Christiansen is currently offline Reinhardt ChristiansenFriend
Messages: 73
Registered: March 2010
Member
Thanks very much for explaining how to find the syntax. I hadn't thought of that. It seemed like the kind of thing that ought to be in the documentation so I didn't know how to find it when it wasn't in the docs and my googling came up empty.
Previous Topic:Widget disposed when using DeleteResourceAction
Next Topic:Feature Request?
Goto Forum:
  


Current Time: Fri Mar 29 00:23:57 GMT 2024

Powered by FUDForum. Page generated in 0.03878 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top