简体   繁体   中英

java maven launch4j no splash screen; same jar and using Launch4J GUI splash screen OR JAVA - JAR: Ok

I'm in the process of migrating a project from ANT to MAVEN.

I managed to create the JAR and also to generate and Windows executable with Maven. Then only thing that is not working is showing the splash screen.

BTW: the JAR file is generated with MAVEN. The same JAR is used in all three situations!

Situations: 1) Running the generated JAR with JAVA -JAR

the splash screen is showing: OK!

2) Building the same JAR with the Launch4J GUI and this configuration file: OK

<?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 using the MAVEN plugin: NO SPLASH SCREEN, NOT OK

Question: What am I missing

<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>

Thanks to the author of the launch4j-maven-plugin plug-in in the end the answer appeared pretty simple:

lukaszlenart commented:
I found the problem, it is in your configuration. The splash screen works because it is defined in a MANIFEST.MF file inside the jar. So launching the jar with java -jar your.jar tells Java to use jar's MANIFEST file to search for a main class and other options. In your configuration you have defined the main class directly which means when launching the app a different method will be used which omits the MANIFEST.MF file, ie: java com.app.YourMainClass -cp your.jar. To resolve that problem you cannot specify the mainClass option in the config, see below:

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM