The following steps will guide you on how to use BuildJRE to create a customized slim version of the JRE for your Maven-based project:
- Download the BuildJRE script.
- Place the script in the root directory of your Maven project, alongside the pom.xml file.
- Add the property
<java.version>Your Version</java.version>to the properties section of your pom.xml.
Note thatmaven.compiler.source/targetcan also use the value ofjava.versionthrough${java.version}. - Build your project using the
mvn packagecommand or any similar command that generates a single JAR file in the/target/directory. - Run the BuildJRE script. It will create a customized slim version of the JRE, which will be located in the
/custom-jre/directory. - If execution of your project using the custom JRE fails, add the unresolved dependencies to a file named
.unresolvable.deps, with each dependency (e.g.,jdk.management.agent) on a separate line. - After modifying the
.unresolvable.depsfile, rerun the BuildJRE script.
By following these steps, you can easily create a customized slim version of the JRE for your Maven project, which can improve the performance of your application and reduce its overall size.