如何使用 Launch4j 和 Maven 创建 .exe 文件

我正在尝试创建项目的 .exe 版本,但不断收到错误。我对 Maven 的经验很少,而且从未尝试过。我已经创建了 .jar 文件,并且 100% 有效。


这是我的pom.xml文件:


<?xml version="1.0" encoding="UTF-8"?>


<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>


    <groupId>org.project1616</groupId>

    <artifactId>Project16x16</artifactId>

    <version>1.0.0</version>


    <name>Project16x16</name>

    <!-- FIXME change it to the project's website -->

    <url>http://www.example.com</url>


    <properties>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <maven.compiler.source>1.8</maven.compiler.source>

        <maven.compiler.target>1.8</maven.compiler.target>

    </properties>


    <repositories>

        <repository>

            <id>repo</id>

            <releases>

                <enabled>true</enabled>

                <checksumPolicy>ignore</checksumPolicy>

            </releases>

            <snapshots>

                <enabled>false</enabled>

            </snapshots>

            <url>file://${project.basedir}/repo</url>

        </repository>

    </repositories>


    <dependencies>

        <dependency>

            <groupId>junit</groupId>

            <artifactId>junit</artifactId>

            <version>4.11</version>

            <scope>test</scope>

        </dependency>

        <dependency>

            <groupId>local</groupId>

            <artifactId>core</artifactId>

            <version>1.0</version>

        </dependency>

        <dependency>

            <groupId>local</groupId>

            <artifactId>DM</artifactId>


犯罪嫌疑人X
浏览 139回答 1
1回答

largeQ

我已经修改了 JRE 详细信息的 launch4j 插件部分。找到下面的代码并使用命令运行mvn clean package。<plugin>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <groupId>com.akathist.maven.plugins.launch4j</groupId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <artifactId>launch4j-maven-plugin</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <executions>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <execution>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <id>l4j-clui</id>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <phase>package</phase>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <goals>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <goal>launch4j</goal>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </goals>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <configuration>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <headerType>gui</headerType>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <jar>target/Project16x16-1.0.0.jar.jar</jar>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <outfile>target/Project16x16.exe</outfile>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <downloadUrl>http://java.com/download</downloadUrl>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <classPath>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <mainClass>org.project16x16.sidescroller.SideScroller</mainClass>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <preCp>anything</preCp>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </classPath>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <jre>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <bundledJre64Bit>false</bundledJre64Bit>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <bundledJreAsFallback>false</bundledJreAsFallback>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <minVersion>1.8.0</minVersion>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <jdkPreference>preferJre</jdkPreference>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <runtimeBits>32</runtimeBits>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </jre>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <versionInfo>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <fileVersion>1.0.0.0</fileVersion>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <txtFileVersion>${project.version}</txtFileVersion>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <fileDescription>${project.name}</fileDescription>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <copyright>2017 spiraluplabs.com</copyright>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <productVersion>1.0.0.0</productVersion>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <txtProductVersion>1.0.0.0</txtProductVersion>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <productName>${project.name}</productName>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <companyName>SpiralUp</companyName>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <internalName>SpiralShareAutoAllocation</internalName>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <originalFilename>SpiralShareAutoAllocation.exe</originalFilename>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </versionInfo>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </configuration>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </execution>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </executions>&nbsp; &nbsp; &nbsp; &nbsp; </plugin>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java