目录
Launch4j介绍
用于创建轻量级Windows本机exe的跨平台Java可执行包装器。提供高级JRE搜索、应用程序启动配置和更好的用户体验。
Cross-platform Java executable wrapper for creating lightweight Windows native EXEs. Provides advanced JRE search, application startup configuration and better user experience.
方式一:Windows exe安装包方式
下载
地址 :Launch4j Executable Wrapper download | SourceForge.net
使用
安装后启动
基本设置
Header设置
Gui 是图像窗口 Consol 是命令窗口
JRE设置
版本信息
保存配置
相关信息设置完成后点击保存相关设置到xml 就会执行打包exe , 相关日志输出Log
运行
运行
方式二:Maven插件集成 【推荐方式】
截至目前最新版本
pom.xml
官方baseDemo :launch4j-demo/pom.xml at master · orphan-oss/launch4j-demo · GitHub
<plugins>
<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<version>2.2.0-SNAPSHOT</version>
<executions>
<execution>
<id>l4j-gui</id>
<phase>package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<!-- header 类型 -->
<headerType>gui</headerType>
<!-- jar位置 -->
<jar>${project.build.directory}/${project.artifactId}-${project.version}.jar</jar>
<!-- exe输出位置 -->
<outfile>${project.build.directory}/app.exe</outfile>
<downloadUrl>http://java.com/download</downloadUrl>
<!-- 自定义classPath 没有可忽略 -->
<classPath>
<mainClass>software.orphan.launch4j.App</mainClass>
<preCp>anything</preCp>
</classPath>
<!-- jre配置 -->
<jre>
<path>%JAVA_HOME%;%PATH%</path> <!-- jre -->
<minVersion>1.8</minVersion> <!-- 版本 -->
<bundledJreAsFallback>true</bundledJreAsFallback>
<jdkPreference>preferJre</jdkPreference>
<requiresJdk>true</requiresJdk>
<bundledJre64Bit>true</bundledJre64Bit>
<runtimeBits>32</runtimeBits>
<!-- vm参数 -->
<opts>
<opt>-Dname=Lukasz</opt>
</opts>
</jre>
<messages>
<bundledJreErr>Test bundledJreErr</bundledJreErr>
</messages>
<!-- 版本信息 -->
<versionInfo>
<fileVersion>1.0.0.0</fileVersion>
<txtFileVersion>${project.version}</txtFileVersion>
<fileDescription>Launch4j Demo App</fileDescription>
<copyright>Lukasz Lenart</copyright>
<productVersion>1.0.0.0</productVersion>
<txtProductVersion>1.0.0.0</txtProductVersion>
<productName>App</productName>
<companyName>Lukasz Lenart</companyName>
<internalName>app</internalName>
<originalFilename>app.exe</originalFilename>
<trademarks>Luk ™</trademarks>
</versionInfo>
</configuration>
</execution>
</executions>
</plugin>
</plugins>