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?