Community
Participate
Working Groups
Using Eclipse 3.0 RC1, build 200405290105. Windows 2000 regional settings are configured for United Kingdom. I ran the following test program at the command line and got "en_GB". I ran it again in Eclipse and got "en_US" as the output. import java.util.Locale; public class Test { public static void main(String[] args) { System.out.println(Locale.getDefault()); } } I added "-nl en_GB" to the eclipse.exe shortcut, restarted the platform and ran it again. I still got "en_US".
The -nl command-line arg is for the instance of Eclipse that you are running. If you run Eclipse with "-nl en_GB" and then go into your prefs (Window -> Preferences -> Plug-in Development -> Target Environment) it will show that you are running in en_GB. When you launch a test program from within Eclipse, you are using a separate VM and the program is getting the Locale information from the operating system. If you set up a launch configuration for a runtime workbench and use the -nl arg, then you will get the correct values in your test workbench.
It seems I didn't make myself clear enough on the initial report, and the -nl might be a red herring. If I run the test program on the command line, the result is "en_GB". If I run the test program in Eclipse, using the same VM, the result is "en_US". It's not a plug-in, just a Java Application. We're trying to get the correct locale (as configured in Windows Regional Settings and recognised by the command-line JVM) when running our program in Eclipse. It seems something in Eclipse is overriding the OS setting, which is not as per DJ's comment.
Here are the exact steps to reproduce (build i0610-1200): - in the Windows control panel set the language to be English (United Kingdom) - run the sample program from the command-line -> output is en_GB - start Eclipse - notice that the Target Environment says nl=en_GB - create a new Java project and run the sample program as a java app. -> output is en_US I have no idea where to start on this one. Adding Jeff and Darin for insight.
This works for me on XP, may be a Win2000 problem. I don't even have to restart Eclipse - I can change it in the control panel and run the program iteratively getting the correct/current locale setting.
works for me on Mac OS (v 10.3.4)
It appears the program picks up the NL setting from the OS, not matter what Eclipse was launched with. I don't think there is anything to be done here.
Locale picks up the settings from the VM (which gets them from the OS by default). You can set locale with the system properties user.language and user.country. Adding "-Duser.country=ES -Duser.language=FR" to the VM arguements of my launch config gave me the (bizarre but) correct output of fr_ES. Note that VM args can be set on the Installed JRE's Preference Page if you always want to run VM's with a locale different from your OS.
Sorry but is -nl really being ignored?
-nl is not being ignored. It launches the workbench with that NL setting. However, the NL of your host workbench does not determine the NL of your target workbench (unless you specify it explicitly). The default NL setting comes from the OS (this just appears to be a "java" thing).
As well, setting the NL of Eclipse, does not determine the NL of target processes - the NL setting comes from the OS unless specified as a system property.
I've changed the description since it was confusing everyone. This bug has nothing to do with the -nl setting, that was a red herring (as pointed out by DJ Houghton). It's also not a Host/Target workbench issue. For me, Eclipse is NOT picking up the locale from the VM/OS settings when running a Java application, but overriding with "en_US". See comment #3 for exact steps to reproduce.
(And you using Win2000? can you try XP to see if it works there? I think this may be a Win2000 bug).
and, what VM are you using (exact version)?
Behavior appears to be VM specific. Using the IBM VM, we pick up the default locale from the OS. Using the Sun VM, the default locale appears to be en_US no matter what the OS setting is.
There's nothing we can do to fix this. It appears to be a VM bug/issue. There is a bug in the Sun Bug Parade database that confirms this: 4989534.
The Sun VM bug mentioned does not apply. I'm using Sun J2SDK 1.4.2_04 on Win2K. When running the test program from the console in the above VM, the locale is correctly detected. When running the test program from Eclipse using the SAME VM, the locale is incorrectly set to en_US.
Sun Bug Parade issue 4989534 was reported on tiger-beta, i.e. 1.5.0 beta 1.
See the related bug: 4854349 for 1.4.2 FULL PRODUCT VERSION : java version "1.4.2-beta" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-beta-b19) Java HotSpot(TM) Client VM (build 1.4.2-beta-b19, mixed mode) Since it works for IBM VM, and not Sun, and we do not pass in anything different, I fail to see how this is an Eclipse bug.
Further investigation points to javaw.exe being the culprit. Eclipse uses "javaw" to launch by default. These launches result in the described in comment #3. Changing the launch config to use "java" instead of "javaw" results in the same behavior that you see from the command line. To use java... Open your launch configuration (Run/Run.../[select your config]), go to the JRE tab, choose "Alternate JRE" radio button, then in the "Java executable" group, select "Alternate" and specify "java". *Of course if isn't on your PATH you'll need to provide the full path to java.exe.