Bug 65945 - Platform ignores setting of OS locale settings
Summary: Platform ignores setting of OS locale settings
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: readme
Depends on:
Blocks:
 
Reported: 2004-06-07 07:30 EDT by Neil Greenwood CLA
Modified: 2004-06-17 12:52 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Neil Greenwood CLA 2004-06-07 07:30:48 EDT
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".
Comment 1 DJ Houghton CLA 2004-06-07 08:56:24 EDT
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.
Comment 2 Neil Greenwood CLA 2004-06-08 03:46:42 EDT
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.
Comment 3 DJ Houghton CLA 2004-06-10 16:42:14 EDT
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.
Comment 4 Darin Wright CLA 2004-06-16 12:28:44 EDT
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.
Comment 5 Kevin Barnes CLA 2004-06-16 17:30:30 EDT
works for me on Mac OS (v 10.3.4)
Comment 6 Darin Wright CLA 2004-06-16 17:32:52 EDT
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.
Comment 7 Kevin Barnes CLA 2004-06-16 18:02:00 EDT
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. 
Comment 8 Jeff McAffer CLA 2004-06-16 23:00:44 EDT
Sorry but is -nl really being ignored?
Comment 9 Darin Wright CLA 2004-06-17 10:21:45 EDT
-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).
Comment 10 Darin Wright CLA 2004-06-17 10:25:13 EDT
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.
Comment 11 Neil Greenwood CLA 2004-06-17 10:30:24 EDT
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.
Comment 12 Darin Wright CLA 2004-06-17 10:32:20 EDT
(And you using Win2000? can you try XP to see if it works there? I think this 
may be a Win2000 bug).
Comment 13 Darin Wright CLA 2004-06-17 10:33:09 EDT
and, what VM are you using (exact version)?
Comment 14 Darin Wright CLA 2004-06-17 11:05:08 EDT
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.
Comment 15 Darin Wright CLA 2004-06-17 11:10:15 EDT
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.
Comment 16 Neil Greenwood CLA 2004-06-17 11:47:38 EDT
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.
Comment 17 Neil Greenwood CLA 2004-06-17 11:50:52 EDT
Sun Bug Parade issue 4989534 was reported on tiger-beta, i.e. 1.5.0 beta 1.
Comment 18 Darin Wright CLA 2004-06-17 11:57:43 EDT
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. 
Comment 19 Kevin Barnes CLA 2004-06-17 12:52:55 EDT
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.