Using maven you can configure this up quite easily, but you do need to have a
multi-module
pom structure
Enable the JLink Maven Plugin
<pluginRepositories> <pluginRepository> <id>apache.snapshots</id> <url>http://repository.apache.org/snapshots/</url> <releases> <enabled>false</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories>Now we can build our distributable
<packaging>jlink</packaging> <build> <plugins> <plugin> <artifactId>maven-jlink-plugin</artifactId> <version>3.0.0-alpha-2-SNAPSHOT</version> <extensions>true</extensions> <configuration> <noHeaderFiles>true</noHeaderFiles> <noManPages>true</noManPages> <stripDebug>true</stripDebug> <verbose>true</verbose> <compress>2</compress> <launcher>customjrelauncher=my.module.app/MyMainClass</launcher> </configuration> <dependencies> <dependency> <groupId>org.ow2.asm</groupId> <artifactId>asm</artifactId> <version>8.0.1</version> </dependency> </dependencies> </plugin> </plugins> </build>This will create a zip file, and an exploded directory containing your JLink image
Running the built module
You can then use any mechanism of your choice to run your application. If you choose to set it per module being run, edit the generated script (in the example above would be
customjrelauncher
- and set the variable at the top to the specified value
Run your application with
java -m my.module/my.module.app.BootMyApp