How can I convert *.sh file to *.exe file?

user13132090 :

I'm working on deploying a standalone application with JavaFx and maven. Everything seems to work fine, but only on my computer. The launcher defined in the pom.xml file is a bash file. Is there any way to convert this file to executable or generate a *.exe using maven which will launch the application? Help, I'm beginner :) Here is my pom.xml file:

<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>
M. S. :

You can use Launch4J. There is a maven plugin that you can use to generate .exe file by running mvn package:

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

Note: Launch4j Configurations can be found here.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=379663&siteId=1