Quick Java Favor
If anyone out there has the JDK installed on Windows, could you run this program and tell me what output you get, and what version of Windows and the JDK you’re using?
import java.nio.charset.*;
public class URLtest {
public static void main(String[] args) {
System.out.println(Charset.defaultCharset());
}
}
Just leave a comment with the info. Thanks.
February 18th, 2013 at 5:06 PM
On Windows XP SP3 (standard U.S. version), I compiled and ran this twice, once with JDK 1.6.0_38 and once with JDK 1.7.0_11. In both cases the answer was “windows-1252″, which is what I’d expect.
February 18th, 2013 at 5:16 PM
What’s more, in version 5 and earlier, there isn’t even a consistent default across all classes: see this StackOverflow page.
February 18th, 2013 at 6:30 PM
windows-1252
Windows 7 Home Premium, SP1, 64-bit, using US English settings
Compiled and run with Oracle JDK 1.7.0_13, 64-bit
February 19th, 2013 at 8:24 AM
Windows 7 Enterprise SP1, 64 bit, with UK English settings
c:\temp>java -version
java version “1.6.0_38″
Java(TM) SE Runtime Environment (build 1.6.0_38-b05)
Java HotSpot(TM) 64-Bit Server VM (build 20.13-b02, mixed mode)
c:\temp>java URLtest
windows-1252
February 27th, 2013 at 2:07 AM
It’s all 32-bit.
$ java -version
java version “1.7.0_13″
Java(TM) SE Runtime Environment (build 1.7.0_13-b20)
Java HotSpot(TM) Client VM (build 23.7-b01, mixed mode)
$ java -cp . URLtest
windows-1252
$ cmd /C ver
Microsoft Windows XP [Version 5.1.2600]
March 31st, 2013 at 10:51 AM
Oracle Java
$ java -version
java version “1.7.0_17″
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
OS X 10.8.3
$ java URLtest
UTF-8
March 31st, 2013 at 10:53 AM
Ooops, didn’t notice until too late you were only looking for Windows.