4

When using an installed version of the JDK, the default system locale is reported correctly, but when I use the adoptopenjdk-11 tar.gz, it is always reported as en_US

import java.util.Locale;

public class CurrentLocale {
    public static void main(String... args) {
        System.out.println("Default locale " + Locale.getDefault());
    }
}

Here is an example of the Homebrew installation of adoptopenjdk11 vs the downloaded and extracted one.

/usr/bin/java CurrentLocale
Default locale ja_JP

~/Downloads/jdk-11.0.8+10/Contents/Home/bin/java CurrentLocale
Default locale en_US

The versions of each JDK are shown here.

# adoptopenjdk-11 (brew cask install adoptopenjdk11)

/usr/bin/java -version
openjdk version "11.0.8" 2020-07-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.8+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.8+10, mixed mode)

# adoptopenjdk-11 (Downloaded from https://adoptopenjdk.net/releases.html?variant=openjdk11&jvmVariant=openj9)

~/Downloads/jdk-11.0.8+10/Contents/Home/bin/java -version
openjdk version "11.0.8" 2020-07-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.8+10)
Eclipse OpenJ9 VM AdoptOpenJDK (build openj9-0.21.0, JRE 11 Mac OS X amd64-64-Bit Compressed References 20200715_677 (JIT enabled, AOT enabled)
OpenJ9   - 34cf4c075
OMR      - 113e54219
JCL      - 95bb504fbb based on jdk-11.0.8+10)

I'm guessing macOS does some magic, because the Java binary symlinked to /usr/bin/java is always there, regardless of whether or not Java happens to be installed.

/usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

The Hotspot (Oracle) version works fine, but the openj9 (IBM) version doesn't work.

I need to bundle the JRE in an installer with an application, and install it to a non-standard location.

How can I get the default locale in the downloaded openj9 tar to mirror the current system's locale?

Traycho Ivanov
  • 2,887
  • 14
  • 24
the_storyteller
  • 2,335
  • 1
  • 26
  • 37

1 Answers1

1

I think this could be related to https://github.com/eclipse/openj9/issues/5705

Traycho Ivanov
  • 2,887
  • 14
  • 24
  • Correct. In fact, the question seems to have been copied from there only. – Arvind Kumar Avinash Aug 17 '20 at 21:26
  • This does explain the language issue being in openj9, but not why the same version worked when installed and didn't work when extracted from an archive. How can I tell which version of Java the change fixes? The fix was merged in May 2019, and Java openj9 11.0.8+10 was built in 2020. In short, I'm still somewhat confused. – the_storyteller Aug 18 '20 at 21:21