Requires Java 9 or above. IBM Semueru Runtimes Java can be obtained here .
To run this sample, first download zip or clone this repo - to clone:
git clone [email protected]:gauthamkrishnanibm/modules-jlink-sample.git
From inside the modules-jlink-sample directory,
javac -d mods/com.foo.bar/ com.foo.bar/module-info.java com.foo.bar/com/foo/bar/HelloWorld.java
mkdir mlib
jar --create --file=mlib/com.foo.bar.hello.jar --module-version=0.0.1 --main-class=com.foo.bar.HelloWorld -C mods/com.foo.bar/ .
java --module-path=mlib --module=com.foo.bar
output:
INFO: Hello World!
java --module-path=mlib --describe-module com.foo.bar
output:
[email protected] file:///helloworld_jlink/mlib/com.foo.bar.hello.jar
requires java.base mandated
requires java.logging
contains com.foo.bar
jlink --module-path=$JAVA_HOME/jmods:mlib --add-modules=com.foo.bar --output=testRuntimeImage --strip-debug --no-header-files
contains com.foo.bar
./testRuntimeImage/bin/java --module com.foo.bar
output:
INFO: Hello World!
./testRuntimeImage/bin/java --list-modules com.foo.bar
output: