I am executing below command to create an image.
jlink --module-path jars/:$JAVA_HOME/jmods --add-modules app.main,app.interfaces.impl,app.interfaces.otherimpl --output image
'app.main' module contains main class.
'app.interfaces.impl' and 'app.interfaces.otherimpl' are modules that implement interfaces in 'app.interfaces' module.
When I create the image using jlink command it creates java and keytool commands in bin folder, but no modules are copied.
$tree
.
├── image
│ ├── bin
│ │ ├── java
│ │ └── keytool
But when I execute 'java --list-modules', it is listing all the modules.
$./image/bin/java --list-modules
app.interfaces
app.interfaces.impl
app.interfaces.otherimpl
app.main
java.base@12.0.1
$
How can I run the main class from app.main module? where exactly the modules copied?
How can I run the main class from app.main module?
Apart from that to execute the main class, you can use the command line:
/image/bin/java -m app.main/app.main.MainClass
or use the --launcher
option to create a launch script in the bin directory, eg
--launcher app=app.main/app.main.MainClass
which create "app" in the bin directory.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.