【问题标题】:Error packaging maven project: launch4j.BuilderException打包maven项目时出错:launch4j.BuilderException
【发布时间】:2022-05-19 18:38:24
【问题描述】:

我有一个主要使用 javafx 在 java 上编写的项目。问题是当我尝试将其打包为 .exe 时,我不断收到以下错误:

   [ERROR]
    net.sf.launch4j.BuilderException: net.sf.launch4j.ExecException: Exec failed (1): C:\Users\Михаил\.m2\repository\com\aka
    thist\maven\plugins\launch4j\launch4j-maven-plugin\1.5.1\launch4j-maven-plugin-1.5.1-workdir-win32\bin\windres.exe --pre
    processor=type -J rc -O coff -F pe-i386 C:\Users\8FEE~1\AppData\Local\Temp\launch4j7244992626989978492rc C:\Users\8FEE~1
    \AppData\Local\Temp\launch4j4703142106425399337o
            at net.sf.launch4j.Builder.build(Builder.java:144)
            at com.akathist.maven.plugins.launch4j.Launch4jMojo.execute(Launch4jMojo.java:353)
            at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
            at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
            at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
            at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.
    java:51)
            at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
            at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
            at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
            at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
            at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
            at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:483)
            at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
            at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
            at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
            at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
    Caused by: net.sf.launch4j.ExecException: Exec failed (1): C:\Users\Михаил\.m2\repository\com\akathist\maven\plugins\lau
    nch4j\launch4j-maven-plugin\1.5.1\launch4j-maven-plugin-1.5.1-workdir-win32\bin\windres.exe --preprocessor=type -J rc -O
     coff -F pe-i386 C:\Users\8FEE~1\AppData\Local\Temp\launch4j7244992626989978492rc C:\Users\8FEE~1\AppData\Local\Temp\lau
    nch4j4703142106425399337o
            at net.sf.launch4j.Util.exec(Util.java:148)
            at net.sf.launch4j.Cmd.exec(Builder.java:205)
            at net.sf.launch4j.Builder.build(Builder.java:97)
            ... 22 more

这是我的 .pom 构建部分:

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <id>unpack-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                            <excludeScope>system</excludeScope>
                            <excludeGroupIds>junit,org.mockito,org.hamcrest</excludeGroupIds>
                            <outputDirectory>${project.build.directory}/classes</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <executions>
                    <execution>
                        <id>unpack-dependencies</id>

                        <phase>package</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>${java.home}/../bin/javafxpackager</executable>
                            <arguments>
                                <argument>-createjar</argument>
                                <argument>-nocss2bin</argument>
                                <argument>-appclass</argument>
                                <argument>${mainClass}</argument>
                                <argument>-srcdir</argument>
                                <argument>${project.build.directory}/classes</argument>
                                <argument>-outdir</argument>
                                <argument>${project.build.directory}</argument>
                                <argument>-outfile</argument>
                                <argument>${project.build.finalName}.jar</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>default-cli</id>
                        <goals>
                            <goal>exec</goal>                            
                        </goals>
                        <configuration>
                            <executable>${java.home}/bin/java</executable>

                        </configuration>
                    </execution>
                </executions>  
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.16</version>
                <configuration>
                    <additionalClasspathElements>
                        <additionalClasspathElement>${java.home}/lib/jfxrt.jar</additionalClasspathElement>
                    </additionalClasspathElements>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>1.7.1</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <shadedArtifactAttached>true</shadedArtifactAttached>
                    <shadedClassifierName>shaded</shadedClassifierName>
                    <transformers>
                        <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                            <mainClass>com.ediagent.edi.gui.Main</mainClass>
                        </transformer>
                    </transformers>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.akathist.maven.plugins.launch4j</groupId>
                <artifactId>launch4j-maven-plugin</artifactId>
                <version>1.5.1</version>
                <executions>
                    <execution>
                        <id>l4j-clui</id>
                        <phase>package</phase>
                        <goals>
                            <goal>launch4j</goal>
                        </goals>
                        <configuration>
                            <headerType>gui</headerType>
                            <jar>${project.build.directory}/${artifactId}-${version}-shaded.jar</jar>
                            <outfile>${project.build.directory}/hasCode.exe</outfile>
                            <downloadUrl>http://java.com/download</downloadUrl>
                            <classPath>
                                <mainClass>com.ediagent.edi.gui.Main</mainClass>
                                <preCp>anything</preCp>
                            </classPath>
                            <icon>src/main/resources/icon/edisoft_ediagent_new_logo.png</icon>
                            <jre>
                                <minVersion>1.6.0</minVersion>
                                <jdkPreference>preferJre</jdkPreference>
                            </jre>
                            <versionInfo>
                                <fileVersion>1.0.0.0</fileVersion>
                                <txtFileVersion>${project.version}</txtFileVersion>
                                <fileDescription>${project.name}</fileDescription>
                                <copyright>2012 hasCode.com</copyright>
                                <productVersion>1.0.0.0</productVersion>
                                <txtProductVersion>1.0.0.0</txtProductVersion>
                                <productName>${project.name}</productName>
                                <companyName>edisoft.ru</companyName>
                                <internalName>ediagent</internalName>
                                <originalFilename>ediagent.exe</originalFilename>
                            </versionInfo>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

我是使用 maven 构建 exe 文件的新手,因此找不到有关如何执行此操作的任何正确信息,所以如果我的配置根本错误,我很抱歉。我知道最好将 java 项目打包到 jar 中,但我需要输出中的 .exe 文件。所以,如果可能的话,请指出我的错误

【问题讨论】:

    标签: java maven javafx maven-plugin launch4j


    【解决方案1】:

    我在打包 javafx 应用程序时遇到了类似的问题,问题是图标在 png 中尝试使用这个 launch4j 插件`

    <plugin>
            <groupId>com.akathist.maven.plugins.launch4j</groupId>
            <artifactId>launch4j-maven-plugin</artifactId>
            <version>1.7.10</version>
            <executions>
                <execution>
                    <id>l4j-clui</id>
                    <phase>package</phase>
                    <goals>
                        <goal>launch4j</goal>
                    </goals>
                    <configuration>
                        <headerType>gui</headerType>
                        <jar>${project.build.directory}/${artifactId}-${version}.jar</jar>
                        <outfile>${project.build.directory}/petrobiz.exe</outfile>
                        <downloadUrl>http://yoururl.com/download</downloadUrl>
                        <classPath>
                            <mainClass>yourmainclass</mainClass>
                            <preCp>anything</preCp>
                        </classPath>
                        <icon>${RESOURCE_PATH}\icon2.ico</icon>
                        <jre>
                            <minVersion>1.8.0</minVersion>
                            <jdkPreference>preferJre</jdkPreference>
                            <bundledJre64Bit>false</bundledJre64Bit>
                            <runtimeBits>64/32</runtimeBits>
                        </jre>
                        <versionInfo>
                            <fileVersion>1.0.0.0</fileVersion>
                            <txtFileVersion>${project.version}</txtFileVersion>
                            <fileDescription>${project.name}</fileDescription>
                            <copyright>2016 yoururl.com</copyright>
                            <productVersion>1.0.0.2</productVersion>
                            <txtProductVersion>1.0.0.0</txtProductVersion>
                            <productName>${project.name}</productName>
                            <companyName>yourcompany</companyName>
                            <internalName>name</internalName>
                            <originalFilename>exename.exe</originalFilename>
                        </versionInfo>
                    </configuration>
                </execution>
            </executions>
        </plugin>`
    

    【讨论】:

      猜你喜欢
      • 2019-07-30
      • 2022-10-01
      • 2019-09-27
      • 1970-01-01
      • 2019-05-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-10
      相关资源
      最近更新 更多