Why does the Oracle JDK (8, 7 and below?) Disregard LC_ * environment variables?

This sample result does not give what I expect with respect to the locale settings ... Although it was compiled and run with Java 8, the problem also manifests itself in Java 7. Both JDKs from Oracle, fully fixed by Ubuntu 13.10.

fge@alustriel:/tmp$ locale
LANG=en_US.UTF-8
LANGUAGE=en_US
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8
fge@alustriel:/tmp$ cat Main.java 
import java.nio.charset.Charset;

public final class Main
{
    public static void main(final String... args)
    {
        System.out.println(Charset.defaultCharset());
        System.out.println(System.getProperty("file.encoding", "UNKNOWN!"));
    }
}
fge@alustriel:/tmp$ javac Main.java
fge@alustriel:/tmp$ java Main
UTF-8
UTF-8
fge@alustriel:/tmp$ LC_ALL=fr_FR.ISO-8859-1 java Main
US-ASCII
ANSI_X3.4-1968

fr_FR.ISO-8859-1installed on my system; why is this the default character set US-ASCII? It is also file.encodingalso set to ASCII, since it ANSI_X3.4-1968looks like an alias for ASCII. Although ISO-8859-1 is fully supported by my system ...

+4
source share

Source: https://habr.com/ru/post/1534723/


All Articles