Search code examples
javalocalejlink

Locale getDisplayLanguage broken in jlink Image


Here an SSCCE:

public class Main {
    public static void main(String[] args) {
        Locale item = Locale.FRANCE;
        System.out.println("Locale: "+item+" displayed: "+item.getDisplayLanguage(Locale.GERMANY));
    }
}

When compiling and running it, it correctly displays

Locale: fr_FR displayed: Französisch

But if I now create a custom runtime image through jlink and run it with it, I get:

Locale: fr_FR displayed: French

No matter which Locale is used, it always falls back to the English one it seems. Perhaps I need an additional module for this? The runtime image is generated like follows:

jlink --module-path "..." --add-modules=java.desktop,java.logging,javafx.controls,javafx.graphics,javafx.fxml,javafx.base,javafx.media --output image

My JDK version:

$ java --version
java 11.0.2 2019-01-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.2+9-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.2+9-LTS, mixed mode)

Solution

  • As stated here, the java.base module only includes the English locale. To build a Jlink image which includes the other locales as well, one must add the jdk.localedata module.