JDK-4891531 : javaw and java get different default locale from OS
  • Type: Bug
  • Component: tools
  • Sub-Component: launcher
  • Affected Version: 1.4.2
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_2000,windows_xp
  • CPU: x86
  • Submitted: 2003-07-16
  • Updated: 2004-04-26
  • Resolved: 2004-04-26
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
5.0 b49Fixed
Related Reports
Duplicate :  
Description

Name: gm110360			Date: 07/16/2003


FULL PRODUCT VERSION :
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)

FULL OS VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
ServicePack 4

EXTRA RELEVANT SYSTEM CONFIGURATION :
German Version

A DESCRIPTION OF THE PROBLEM :
Java program which was started with java gets an other default locale than a program which was started with javaw.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Changing OS locale to other locale (Start->Settings->ControlPanel->RegionalOptions).
Java program reads out default locale with Locale.getDefault() and gives it out.
Starting java program with java: class gets correct (changed) locale from OS.
Starting java program with javaw: class gets locale from before the changes.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Starting java program with java: class gets correct (changed) locale from OS.
Starting java program with javaw: class gets correct (changed) locale from OS.
ACTUAL -
Starting java program with java: class gets correct (changed) locale from OS.
Starting java program with javaw: class gets locale from before the changes.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.util.*;
import java.io.*;

public class Test
{
   public static void main(String[] args)
   {
      Locale myLocale = Locale.getDefault();
      File f = new File("test.txt");
      try
      {
         FileOutputStream fos = new FileOutputStream(f);
         fos.write(myLocale.toString().getBytes());
      }
      catch(FileNotFoundException fnfe)
      {
         fnfe.printStackTrace();
      }
      catch(IOException io)
      {
         io.printStackTrace();
      }
   }
}
---------- END SOURCE ----------
(Incident Review ID: 191650) 
======================================================================

Name: rmT116609			Date: 07/21/2003


FULL PRODUCT VERSION :
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)

FULL OS VERSION :
Microsoft Windows XP [Version 5.1.2600]

EXTRA RELEVANT SYSTEM CONFIGURATION :
User Default Locale : 3079
System Default Locale : 1033
Country : Austria
Language : German (Austria)
Time Zone : W. Europe Standard Time
ANSI Code Page : 1252
OEM Code Page : 850


A DESCRIPTION OF THE PROBLEM :
The JRE uses the wrong default locale when "javaw" is used.

Note: this is an update for
http://developer.java.sun.com/developer/bugParade/bugs/4854349.html

Might be related to
http://developer.java.sun.com/developer/bugParade/bugs/4629351.html


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Set the locales as shown above.
Run the example code.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should always report "default: de_AT"
ACTUAL -
When run with "javaw" reports: "default: en_US"

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.JOptionPane;
import java.util.Locale;

public class Demo {
	public static void main(String[] args) {
		JOptionPane.showMessageDialog(null, "default: " +Locale.getDefault());
		System.exit(0);
	}
}
---------- END SOURCE ----------
(Review ID: 189582)
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger-beta2 FIXED IN: tiger-beta2 INTEGRATED IN: tiger-b49 tiger-beta2
14-06-2004

WORK AROUND Set both Your locale & system locale to be the same.
11-06-2004

EVALUATION I changed both system locale and user locale to be the same and the test returned what I set for both java & javaw. tested on win2k with tiger 1.5 However if I don't set system locale then it will return en_us. ###@###.### 2003-08-26 fix in tiger-beta2 ###@###.### 2004-04-21
26-08-2003