I'm using spring-boot-maven-plugin to repackage all my classes and depending jars into single self-contained jar file. I can double-click this jar on Windows to execute my application.
However, when I use this large jar and package into launch4j executable I cannot start the resulting .exe anymore. I've inspected the jar and the executable and see that the folder structure created by the spring boot plugin is much different than compared to the maven shade plugin.
As a result it looks like the javaw command can't find the main class anymore since it's in WEB-INF/classes/<packages>/<main-class>.
I've verified this on the console using:</main-class></packages>
If I replace the spring-boot-maven-plugin repackage with maven shade plugin, then the large jar has different folder structure and the launch4j generated .exe can be executed on Windows with double-click, as well as with the java -cp <my-app>.exe <main-class> command.
Is there a way to use the spring-boot generated self-contained jar with launch4j? Anything I must use differently?
Last edit: DonT 2021-10-18
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The spring boot repackaging mechanism moves your normal Main-Class in the JAR manifest into a Spring-specific attribute and sets Main-Class to point to a Spring bootstrapping class org.springframework.boot.loader.JarLauncher which reads the manifest and executes the real main class. So you need to tell launch4j to do the same thing, and configure it with org.springframework.boot.loader.JarLauncher as the main class.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm using spring-boot-maven-plugin to repackage all my classes and depending jars into single self-contained jar file. I can double-click this jar on Windows to execute my application.
However, when I use this large jar and package into launch4j executable I cannot start the resulting .exe anymore. I've inspected the jar and the executable and see that the folder structure created by the spring boot plugin is much different than compared to the maven shade plugin.
As a result it looks like the javaw command can't find the main class anymore since it's in WEB-INF/classes/<packages>/<main-class>.
I've verified this on the console using:</main-class></packages>
If I replace the spring-boot-maven-plugin repackage with maven shade plugin, then the large jar has different folder structure and the launch4j generated .exe can be executed on Windows with double-click, as well as with the
java -cp <my-app>.exe <main-class>
command.Is there a way to use the spring-boot generated self-contained jar with launch4j? Anything I must use differently?
Last edit: DonT 2021-10-18
The spring boot repackaging mechanism moves your normal
Main-Class
in the JAR manifest into a Spring-specific attribute and setsMain-Class
to point to a Spring bootstrapping classorg.springframework.boot.loader.JarLauncher
which reads the manifest and executes the real main class. So you need to tell launch4j to do the same thing, and configure it withorg.springframework.boot.loader.JarLauncher
as the main class.That was it! Thanks so much.