Closed vorburger closed 5 years ago
oh hang on while this works for Java 11 it produces this for the Java 8 image:
No package java-1.8.0-openjdk-jmods-1.8.0.181-3.b13.el7_5 available.
Unfortunately that message is tucked away in the build and hard to see - it ideally really should fail for unknown packages IMHO.
ideally really should fail for unknown packages IMHO
yum --setopt=skip_missing_names_on_install=False
I guess this can be ignored:
Main config did not have a skip_missing_names_on_install attr. before setopt
@gunnarmorling I like to do TDD even for something like this - can you propose a test command to run to verify if whatever java-11-openjdk-jmods
adds actually works in the container (and which fails if it's not installed) ?
@vorburger Yes, I think the jmods package should be part of the image for JDK 11 (but not 8, where it doesn't exist, as you found out).
In order to test it, you could run the jlink tool. This creates a small variant of the JDK only containing selected modules (well, it will be really small if that bug has been resolved ;)). The jmods package contains the module files of the JDK which will be used by jlink for creating such "modular runtime images".
The following shows an example. It produces a runtime image with simple main class and a launcher script:
mkdir -p src/main/java/com/example
mkdir modules
cat > src/main/java/com/example/Main.java << EOF
package com.example;
public class Main {
public static void main(String... args) {
System.out.println("Hello, jlink!");
}
}
EOF
cat > src/main/java/module-info.java << EOF
module com.example {
}
EOF
javac -g -d modules/com.example $(find src/main/java -name "*.java")
jlink --module-path modules --add-modules com.example --output img --launcher run=com.example/com.example.Main
Running this image via the created launcher script will print "Hello, jlink", if everything works as it should (note the image is fully self-contained at this point, i.e. it also could run on another system without a Java installation):
./img/bin/run
@gunnarmorling I've just merged this, so you now have java-11-openjdk-jmods
.
Thanks a lot for the full example - to be picked up in # 181!
Reverted this again, for now; see #181.
@gunnarmorling do you think this should be part of the base image?