java.base missing while trying jlink

1.5k views Asked by At

I am getting this Error: Module java.base not found while trying to use jlink.

These are the 2 things I have tried so far

/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/bin/jlink --module-path "%JAVA_HOME%\jmods":mods --add-modules com.tutorialspoint.greetings,java.base --output customjre
Error: Module java.base not found

/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/bin/jlink --module-path "%JAVA_HOME%\jmods":mods --add-modules com.tutorialspoint.greetings,[email protected] --output customjre
Error: Module [email protected] not found

My module contains this.

module com.tutorialspoint.greetings { 
    requires java.base;
}

I followed this tutorial for making modules exactly except I added the requires java.basic. https://www.tutorialspoint.com/java9/java9_module_system.htm

I tried it without requires java.base and still get the same problem. Any ideas? I am new to JLink and Java9 and wanted to try it since java8 doesn't have Jlink.

Maybe it's how I am referencing to JLink in the directory itself?

1

There are 1 answers

0
bedril moussakat On

The problem comes from the fact that the path of the module is poorly defined.

If you are on macos, the correct syntax is:

jlink --module-path "mods:$JAVA_HOME/jmods" --add-modules com.tutorialspoint.greetings --output customjre

Make sure the JAVA_HOME variable is set before running the jlink.

Also, it is not necessary to define the requires clause with the java.base module in your module because the java.base module is implicitly added in all modules.