java - 打包maven项目时出错: launch4j. BuilderException

标签 java maven javafx maven-plugin launch4j

我有一个主要使用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 文件。所以,如果可能的话,请指出我的错误

最佳答案

我在打包 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>`

关于java - 打包maven项目时出错: launch4j. BuilderException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30457161/

相关文章:

java - 单击新 View 时如何删除 setBackgroundResource?

Java : Class wrapper using generic

java - 无法在 glassfish 中运行,日志中出现奇怪的输入流错误

JavaFX:更改文本区域中的光标

java - 为 JavaFX 按钮数组中的每个按钮分配一个操作

Java:如何根据对象的类型动态创建指定类型的数组?

java - Hadoop的TooRunner是线程安全的吗?

java - Jenkins 错误启动静态资源

java - 仅包含带有 Spring Boot maven 插件的配置文件的源包和依赖项

javafx如何禁用checkboxTreeItem中的一项?