我正在将项目从ANT迁移到MAVEN。
我设法创建了JAR,并使用Maven生成Windows可执行文件。然后,只有不起作用的东西才会显示启动画面。
BTW:使用MAVEN生成JAR文件。 在所有三种情况下都使用相同的JAR!
情况:
1)使用JAVA -JAR
启动画面显示:确定!
2)使用Launch4J GUI和此配置文件构建相同的JAR:确定
<?xml version="1.0" encoding="UTF-8"?>
<launch4jConfig>
<dontWrapJar>false</dontWrapJar>
<headerType>gui</headerType>
<jar>D:\Source\Java\ClientApplications\JavaTest\LrAnalyzer\target\LR Analyzer.jar</jar>
<outfile>D:\Source\Java\ClientApplications\JavaTest\LrAnalyzer\target\LR Analyzer.exe</outfile>
<errTitle></errTitle>
<cmdLine></cmdLine>
<chdir></chdir>
<priority>normal</priority>
<downloadUrl>http://java.com/download</downloadUrl>
<supportUrl></supportUrl>
<stayAlive>false</stayAlive>
<manifest></manifest>
<icon>D:\Dropbox\Jasper rapporten\Website\Icoontjes, plaatjes\Logo LightroomStatistics\logo alone.ico</icon>
<jre>
<path>jre</path>
<bundledJre64Bit>false</bundledJre64Bit>
<minVersion>1.7.0</minVersion>
<maxVersion></maxVersion>
<jdkPreference>preferJre</jdkPreference>
<runtimeBits>64/32</runtimeBits>
</jre>
</launch4jConfig>
3使用MAVEN插件:没有SPLASH SCREEN,不行
问题:我缺少什么
<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<version>1.7.21</version>
<executions>
<execution>
<id>${project.name}</id>
<phase>package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<headerType>gui</headerType>
<jar>${project.build.directory}/${project.name}.jar</jar>
<outfile>${project.build.directory}/${project.name}.exe</outfile>
<downloadUrl>http://java.com/download</downloadUrl>
<classPath>
<mainClass>com.lightroomstatistics.main.LightroomStatisticsViewer</mainClass>
<preCp>anything</preCp>
</classPath>
<icon>D:\Dropbox\Jasper rapporten\Website\Icoontjes,
plaatjes\Logo LightroomStatistics\logo alone.ico</icon>
<jre>
<minVersion>1.8.0</minVersion>
<jdkPreference>preferJre</jdkPreference>
</jre>
<versionInfo>
<fileVersion>1.0.0.0</fileVersion>
<txtFileVersion>${project.version}</txtFileVersion>
<fileDescription>${project.name}</fileDescription>
<copyright>2017 LightroomStatistics</copyright>
<productVersion>1.0.0.0</productVersion>
<txtProductVersion>1.0.0.0</txtProductVersion>
<productName>${project.name}</productName>
<companyName>LightroomStatistics.com</companyName>
<internalName>LightroomStatistics</internalName>
<originalFilename>LR-Analyzer.exe</originalFilename>
</versionInfo>
</configuration>
</execution>
</executions>
</plugin>
答案 0 :(得分:0)
感谢launch4j-maven-plugin的作者 插件到底答案看起来很简单:
lukaszlenart评论说:
我发现了问题,它在您的配置中。启动画面有效,因为它是在jar内的MANIFEST.MF文件中定义的。因此,使用java -jar启动jar.jar告诉Java使用jar的MANIFEST文件来搜索主类和其他选项。在您的配置中,您已直接定义了主类,这意味着在启动应用程序时将使用另一种省略MANIFEST.MF文件的方法,即:java com.app.YourMainClass -cp your.jar。要解决该问题,您无法在配置中指定mainClass选项,请参阅以下内容:
<configuration>
<headerType>gui</headerType>
<jar>${project.basedir}/target/${project.name}.jar</jar>
<downloadUrl>http://java.com/download</downloadUrl>
<!-- Update to the local resource path -->
<icon>${project.basedir}/src/main/resources/logo_alone.ico</icon>
<jre>
<minVersion>1.8.0</minVersion>
<jdkPreference>preferJre</jdkPreference>
</jre>
<versionInfo>
<fileVersion>1.0.0.0</fileVersion>
<txtFileVersion>${project.version}</txtFileVersion>
<fileDescription>${project.name}</fileDescription>
<copyright>2017 LightroomStatistics</copyright>
<productVersion>1.0.0.0</productVersion>
<txtProductVersion>1.0.0.0</txtProductVersion>
<productName>${project.name}</productName>
<companyName>LightroomStatistics.com</companyName>
<internalName>LightroomStatistics</internalName>
<originalFilename>LR-Analyzer.exe</originalFilename>
</versionInfo>
</configuration>