【问题标题】:How can I convert *.sh file to *.exe file?如何将 *.sh 文件转换为 *.exe 文件?
【发布时间】:2020-03-27 11:34:45
【问题描述】:

我正在使用 JavaFx 和 maven 部署一个独立的应用程序。一切似乎都很好,但只在我的电脑上。 pom.xml 文件中定义的启动器是一个 bash 文件。有没有办法将此文件转换为可执行文件或使用 maven 生成 *.exe 来启动应用程序?帮助,我是初学者:) 这是我的 pom.xml 文件:

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.example</groupId>
    <artifactId>gowno</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>13</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>13</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <release>11</release>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.3</version>
                <configuration>
                    <mainClass>org.example.App</mainClass>
                    <launcher>launch.sh</launcher>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

【问题讨论】:

标签: java maven javafx


【解决方案1】:

您可以使用Launch4J。有一个 maven 插件,您可以通过运行 mvn package 来生成 .exe 文件:

<plugins>
    <plugin>
        <groupId>com.akathist.maven.plugins.launch4j</groupId>
        <artifactId>launch4j-maven-plugin</artifactId>
        <version>1.7.25</version>
        <executions>
            <execution>
                <id>l4j-gui</id>
                <phase>package</phase>
                <goals>
                    <goal>launch4j</goal>
                </goals>
                <configuration>
                    <headerType>gui</headerType>
                    <outfile>${artifast.bin.dir}/${project.name}.exe</outfile>
                    <jar>${artifast.bin.dir}/${project.name}.jar</jar>
                    <errTitle>Error</errTitle>
                    <classPath>
                        <mainClass>com.mycompany.app.Gui</mainClass>
                    </classPath>
                    <jre>
                        <minVersion>1.8.0</minVersion>
                    </jre>
                    <versionInfo>
                        <fileVersion>1.2.3.4</fileVersion>
                        <txtFileVersion>txt file version?</txtFileVersion>
                        <fileDescription>a description</fileDescription>
                        <copyright>my copyright</copyright>
                        <productVersion>4.3.2.1</productVersion>
                        <txtProductVersion>txt product version</txtProductVersion>
                        <productName>PRODUCT NAME</productName>
                        <internalName>internal name</internalName>
                        <originalFilename>${project.name}.exe</originalFilename>
                    </versionInfo>
                </configuration>
            </execution>
        </executions>
    </plugin>
<plugins>

注意:可以在here找到Launch4j配置。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多