在自包含JavaFX应用程序

时间:2015-07-08 16:07:36

标签: java maven javafx javafx-8

我一直在与这个战斗超过一天,并在SO和其他地方阅读了很多帖子,但我仍然遇到问题。

我需要在自包含的JavaFX应用程序包中包含我的应用程序图标。我正在使用JDK 1.8.0_45及其包含的JavaFX包。我正在使用Maven来构建.exe,除了我不能包含我的图标外,一切都很好。

这是我的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>

    <prerequisites>
        <maven>2.2.1</maven>
    </prerequisites>

    <groupId>com.mycompany.drm</groupId>
    <artifactId>DRMDashboard</artifactId>
    <version>2.0</version>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <javafx.version>8.0.45</javafx.version>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <!-- copy all dependencies of your app to target folder-->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.10</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <configuration>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>false</overWriteSnapshots>
                            <overWriteIfNewer>true</overWriteIfNewer>
                        </configuration>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <archive>
                        <manifestEntries>
                            <JavaFX-Version>${javafx.version}+</JavaFX-Version>
                            <Main-Class>com.mycompany.client.HelloWorld</Main-Class>
                            <implementation-version>2.0</implementation-version>
                            <JavaFX-Application-Class>com.mycompany.client.HelloWorld</JavaFX-Application-Class>
                            <JavaFX-Class-Path>
                                <!-- list all your dependencies here-->

                            </JavaFX-Class-Path>
                            <!-- The artifactId (name) of the jfxrt.jar ... see dependency system scope-->
                            <Class-Path>
                                javafx-${javafx.version}.jar
                            </Class-Path>
                        </manifestEntries>
                        <manifest>
                            <addClasspath>true</addClasspath>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.6</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <configuration>
                            <target>

                                <path id="mypath">
                                    <pathelement path="${maven.plugin.classpath}"/>
                                    <fileset dir="${project.basedir}">
                                        <include name="package/windows/DRMDashboard.ico"/>
                                    </fileset>
                                </path>

                                <!-- define the deploy ANT task-->
                                <taskdef name="jfxdeploy" classname="com.sun.javafx.tools.ant.DeployFXTask"
                                         classpathref="mypath" />
                                <!-- define the JarSign ANT task-->
                                <taskdef name="jfxsignjar" classname="com.sun.javafx.tools.ant.FXSignJarTask"
                                         classpathref="maven.plugin.classpath" />
                                <jfxdeploy outdir="${project.build.directory}/deploy"
                                           outfile="DRMDashboard"
                                           nativeBundles="exe"
                                           verbose="true">
                                    <info title="DRM Dashboard" vendor="My Company, Inc."/>
                                    <application name="DRMDashboard" mainClass="com.mycompany.client.HelloWorld" version="2.0" />
                                    <resources>
                                        <fileset dir="${project.build.directory}" includes="*.jar" />
                                                 <!--includes="*.jar" />-->
                                    </resources>
                                    <!-- set your jvm args-->
                                    <platform javafx="${javafx.version}+">
                                        <jvmarg value="-Xms512m" />
                                        <jvmarg value="-Xmx1024m" />
                                    </platform>
                                    <preferences install="false" menu="true" shortcut="true"/>
                                </jfxdeploy>
                                <!-- you need to generate a key yourself -->
                                <jfxsignjar destdir="${project.build.directory}/deploy"
                                            keyStore="c:/Users/me/DRMDashboard.ks" storePass="****" alias="DRMDashboard"
                                            keyPass="****">
                                    <fileset dir="${project.build.directory}/deploy"
                                             includes="*.jar" />
                                </jfxsignjar>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>com.oracle</groupId>
                        <artifactId>ant-javafx</artifactId>
                        <version>${javafx.version}</version>
                        <systemPath>${java.home}/../lib/ant-javafx.jar</systemPath>
                        <scope>system</scope>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
        <finalName>DRMDashboard</finalName>
    </build>
</project>

编辑1:以下是我的文件浏览器的屏幕截图: enter image description here

编辑2:以下是展开的目标文件夹的屏幕截图: enter image description here

当我使用verbose标志执行构建时,我收到以下消息:

main:
No base JDK. Package will use system JRE.
  Using default package resource [application icon]  (add package/windows/DRMDashboard.ico to the class path to customize)
Icon File Name: C:\Users\jernst\AppData\Local\Temp\fxbundler8622978628378929412\windows\DRMDashboard.ico
Executable File Name: C:\Users\jernst\AppData\Local\Temp\fxbundler8622978628378929412\images\win-exe.image\DRMDashboard\DRMDashboard.exe
  Config files are saved to C:\Users\jernst\AppData\Local\Temp\fxbundler8622978628378929412\windows. Use them to customize package.
  Using default package resource [Inno Setup project file]  (add package/windows/DRMDashboard.iss to the class path to customize)
  Using default package resource [setup dialog icon]  (add package/windows/DRMDashboard-setup-icon.bmp to the class path to customize)
Using default package resource [script to run after application image is populated]  (add package/windows/DRMDashboard-post-image.wsf to the class path to customize)

我已尝试使用Oracle Documentation中描述的“Drop In Resources”,但无论我尝试将类路径设置为正确,它都无法识别我的自定义图标

编辑3: 我使用了NwDx建议的使用javapackager而不是ant任务的方法,我已经非常接近我需要的东西了。现在我唯一的问题是对话框图标仍然使用通用java咖啡杯: enter image description here

这是我目前的POM:

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

    <prerequisites>
        <maven>2.2.1</maven>
    </prerequisites>

    <groupId>com.autoap.drm</groupId>
    <artifactId>native_drm</artifactId>
    <version>2.0</version>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <javafx.version>8.0.45</javafx.version>
        <mainClass>com.autoap.client.DRMDashboard</mainClass>
        <application.title>DRMDashboard</application.title>
        <organization.name>AutoAp, Inc.</organization.name>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <!-- copy all dependencies of your app to target folder-->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.10</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <configuration>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>false</overWriteSnapshots>
                            <overWriteIfNewer>true</overWriteIfNewer>
                        </configuration>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <archive>
                        <manifestEntries>
                            <JavaFX-Version>${javafx.version}+</JavaFX-Version>
                            <Main-Class>com.autoap.client.DRMDashboard</Main-Class>
                            <implementation-version>2.0</implementation-version>
                            <JavaFX-Application-Class>com.autoap.client.DRMDashboard</JavaFX-Application-Class>
                            <JavaFX-Class-Path>
                                <!-- list all your dependencies here-->

                            </JavaFX-Class-Path>
                            <!-- The artifactId (name) of the jfxrt.jar ... see dependency system scope-->
                            <Class-Path>
                                javafx-${javafx.version}.jar
                            </Class-Path>
                        </manifestEntries>
                        <manifest>
                            <addClasspath>true</addClasspath>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>

             <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.4.0</version>
                <executions>
                    <!-- Create the jar file -->
                    <execution>
                        <id>createjar</id>

                        <phase>package</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>

                        <configuration>
                            <executable>${java.home}/../bin/javapackager</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>

                    <!-- Sign the jar -->
                    <!-- Can't test, because I don't have the files
                    <execution>
                        <id>signjar</id>

                        <phase>package</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>

                        <configuration>
                            <executable>${java.home}/../bin/javapackager</executable>
                            <arguments>
                                <argument>-signjar</argument>
                                <argument>-alias</argument>
                                <argument>${application.title}</argument>
                                <argument>-keyPass</argument>
                                <argument>****</argument>
                                <argument>-keyStore</argument>
                                <argument>C:/Users/me/DRMDashboard.ks</argument>
                                <argument>-storePass</argument>
                                <argument>*****</argument>
                                <argument>-outdir</argument>
                                <argument>${project.build.directory}</argument>
                                <argument>-srcdir</argument>
                                <argument>${project.build.directory}</argument>
                                <argument>-srcfiles</argument>
                                <argument>${project.build.finalName}.jar</argument>
                            </arguments>
                        </configuration>
                    </execution> -->

                    <!-- Deploy a native version -->
                    <execution>
                        <id>deploy</id>

                        <phase>package</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>${java.home}/../bin/javapackager</executable>
                            <arguments>
                                <argument>-deploy</argument>
                                <argument>-appclass</argument>
                                <argument>${mainClass}</argument>
                                <argument>-native</argument>
                                <argument>exe</argument>
                                <argument>-srcdir</argument>
                                <argument>${project.build.directory}</argument>
                                <argument>-srcfiles</argument>
                                <argument>${project.build.finalName}.jar</argument>
                                <argument>-outdir</argument>
                                <argument>${project.build.directory}/dist</argument>
                                <argument>-outfile</argument>
                                <argument>${project.build.finalName}</argument>
                                <argument>-Bicon=${project.build.directory}/classes/${application.title}.ico</argument>
                                <argument>-BappVersion=${project.version}</argument>
                                <argument>-Bcopyright='2015 AutoAp, Inc.'</argument>
                                <argument>-BshortcutHint=true</argument>
                                <argument>-BsystemWide=false</argument>
                                <argument>-Bwin.menuGroup=${organization.name}</argument>
                                <argument>-Bvendor=${organization.name}</argument>
                                <argument>-v</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>default-cli</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>${java.home}/bin/java</executable>
                            <commandlineArgs>-jar '${project.build.directory}/${project.build.finalName}.jar'</commandlineArgs>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <finalName>DRMDashboard</finalName>
    </build>
</project>

使图标显示在标题栏中的是javapackager部署步骤的-Bicon=${project.build.directory}/classes/${application.title}.ico参数。该行告诉inno安装程序使用该图标。拼图的最后一部分是如何使用bmp作为对话框图像。这是日志文件的相关位:

Running [C:\Program Files\Java\jdk1.8.0_45\jre\bin\java, -version]
Running [C:\Program Files (x86)\Inno Setup 5\iscc.exe, /?]
  Detected [C:\Program Files (x86)\Inno Setup 5\iscc.exe] version [5]
   Using custom package resource [application icon]  (loaded from file C:\Users\jernst\IdeaProjects\AutoAp\native_drm\target\classes\DRMDashboard.ico)
Running [C:\Users\jernst\AppData\Local\Temp\iconswap106251599206027586.exe, C:\Users\jernst\AppData\Local\Temp\fxbundler6949394438624826643\windows\DRMDashboard.ico, C:\Users\jernst\AppData\Local\Temp\fxbundler6949394438624826643\images\win-exe.image\DRMDashboard\DRMDashboard.exe]
Icon File Name: C:\Users\jernst\AppData\Local\Temp\fxbundler6949394438624826643\windows\DRMDashboard.ico
Executable File Name: C:\Users\jernst\AppData\Local\Temp\fxbundler6949394438624826643\images\win-exe.image\DRMDashboard\DRMDashboard.exe
  Config files are saved to C:\Users\jernst\AppData\Local\Temp\fxbundler6949394438624826643\windows. Use them to customize package.
  Using default package resource [Inno Setup project file]  (add package/windows/DRMDashboard.iss to the class path to customize)
  Using default package resource [setup dialog icon]  (add package/windows/DRMDashboard-setup-icon.bmp to the class path to customize)
Using default package resource [script to run after application image is populated]  (add package/windows/DRMDashboard-post-image.wsf to the class path to customize)
Generating EXE for installer to: C:\Users\jernst\IdeaProjects\AutoAp\native_drm\target\dist\bundles
Running [C:\Program Files (x86)\Inno Setup 5\iscc.exe, /oC:\Users\jernst\IdeaProjects\AutoAp\native_drm\target\dist\bundles, C:\Users\jernst\AppData\Local\Temp\fxbundler6949394438624826643\images\win-exe.image\DRMDashboard.iss] in C:\Users\jernst\AppData\Local\Temp\fxbundler6949394438624826643\images\win-exe.image
Inno Setup 5 Command-Line Compiler

您可以看到它在哪里找到我的自定义应用程序图标,但它找不到自定义设置对话框图标。

4 个答案:

答案 0 :(得分:13)

先决条件/假设

  • 您使用的是Windows(7,8,8.1)
  • 至少在1.8.0版本(包括javafx)中安装了JDK
  • 您已将JAVA_HOME环境变量设置为指向JDK的顶级目录(例如C:\ Program Files \ Java \ jdk1.8.0_45)
  • 至少在5.5.5版本中安装了Inno Setup(首选版本为unicode)
  • 您已经有一个图标文件(256 x 256px),首选多尺寸图标。我建议访问此网站:http://icoconvert.com/
  • 您已将安装程序安装程序的bmp文件(48 x 48像素)设置为设置图标

解决方案

项目结构

首先,您需要在有效结构中设置Project,如下所示: 您的包文件夹必须位于项目根文件夹中,而不是在src或资源等任何子文件夹中。

ProjectStructur

的pom.xml

正确部署需要更多属性。正如您在antrun插件部分中所看到的,您需要在调用构建文件之前重新分配ant环境的属性。属性自动设置为被调用的构建文件。 Normaly Intellij Idea将在项目根目录中为您创建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>com.autoap</groupId>
    <artifactId>HelloWorld</artifactId>
    <version>2.0</version>
    <packaging>jar</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <mainClass>com.autoap.client.HelloWorld</mainClass>
        <application.title>${project.artifactId}</application.title>
        <copyright>Han Solo</copyright>
    </properties>

    <organization>
        <name>Star Wars</name>
    </organization>

    <build>
        <plugins>
            <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>default-cli</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>${java.home}/bin/java</executable>
                            <commandlineArgs>-jar '${project.build.directory}/dist/${project.build.finalName}-${project.version}.jar'
                            </commandlineArgs>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.8</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <configuration>
                            <target>
                                <property name="compile_classpath" refid="maven.compile.classpath"/>
                                <property name="outputDir" value="${project.build.outputDirectory}"/>
                                <property name="sourceDir" value="${project.build.sourceDirectory}"/>
                                <property name="distDir" value="${project.build.outputDirectory}/../dist"/>
                                <property name="javaHome" value="${java.home}"/>
                                <property name="versionNo" value="${project.version}"/>
                                <property name="mainClass" value="${mainClass}" />
                                <property name="appName" value="${application.title}"/>
                                <property name="appTitle" value="${application.title}"/>
                                <property name="appVendor" value="${project.organization.name}"/>
                                <property name="appCopyright" value="${copyright}"/>
                                <property name="appMenuGroup" value="${project.organization.name}"/>
                                <ant antfile="${basedir}/build.xml" target="default"/>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

的build.xml

我试图将它与loosley耦合,因此通常不需要更改该文件中的任何内容。仅当您想要签名或特殊行为等时.build.xml文件应保存在项目根目录中。

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

<project name="App" default="default" basedir="."
         xmlns:fx="javafx:com.sun.javafx.tools.ant">


    <target name="default" depends="clean,compile">

        <!-- defines the classpath -->
        <path id="cp">
            <filelist>
                <file name="${javaHome}/../lib/ant-javafx.jar"/>
                <file name="${basedir}" />
            </filelist>
        </path>

        <!-- defines the task with a reference to classpath -->
        <taskdef resource="com/sun/javafx/tools/ant/antlib.xml"
                 uri="javafx:com.sun.javafx.tools.ant"
                 classpathref="cp"/>


        <fx:application id="appId"
                        name="${appName}"
                        mainClass="${mainClass}"
                        version="${versionNo}"/>


        <!-- Defines the resources needed by the application -->
        <fx:resources id="appRes">
            <fx:fileset dir="${distDir}" includes="${appName}-${versionNo}.jar"/>
        </fx:resources>

        <!-- Create a jar file -->
        <fx:jar destfile="${distDir}/${appName}-${versionNo}.jar">
            <fx:application refid="appId"/>
            <fx:resources refid="appRes"/>
            <fileset dir="${outputDir}"/>
        </fx:jar>

        <fx:deploy width="300" height="250"
                   outdir="${distDir}" embedJNLP="true"
                   outfile="${appName}-${versionNo}"
                   nativebundles="exe" verbose="true">

            <!-- define for ex. min javafx version -->
            <!-- <fx:platform /> -->

            <!-- defines the application and setup preferences -->
            <fx:preferences shortcut="true" install="true" menu="true"/>

            <!-- defines the application parts -->
            <fx:application refId="appId"/>

            <!-- defines the needed resources -->
            <fx:resources refid="appRes"/>

            <!-- defines the application info details -->
            <fx:info title="${appTitle}"
                     vendor="${appVendor}"
                     copyright="${appCopyright}"/>

            <!-- Some bundle arguments only for special platforms -->
            <fx:bundleArgument arg="win.menuGroup" value="${appMenuGroup}"/>
        </fx:deploy>

    </target>

    <!-- Removes the folders of previous runs -->
    <target name="clean">
        <mkdir dir="${outputDir}"/>
        <mkdir dir="${distDir}"/>

        <delete>
            <fileset dir="${outputDir}" includes="**/*"/>
            <fileset dir="${distDir}" includes="**/*"/>
        </delete>
    </target>

    <!-- Compiles the sources -->
    <target name="compile" depends="clean">
        <javac includeantruntime="false"
               srcdir="${sourceDir}"
               destdir="${outputDir}"
               fork="yes"
               executable="${javaHome}/../bin/javac"
               source="1.8"
               debug="on">
        </javac>
    </target>

</project>

包文件夹中的图像

需要重命名包文件夹中的图像。图标文件需要完全(区分大小写),在maven pom中命名为属性application.title。第二个文件是设置图标,它需要确切的应用程序标题作为第一部分,-setup-icon.bmp作为最后一部分。它需要是一个bmp。上面提到的尺寸。

IconNaming

我的图片看起来像这样:

IconFiles

运行配置

您现在唯一需要的是运行脚本来部署它。为此,您需要一个特殊的运行配置,如在下一个屏幕中显示:

RunConfig

应用

配置完运行后,运行它,您将获得该应用程序。我的应用程序没有什么特别的默认Hello World示例,它看起来像:

App

exe安装程序的路径

在你的项目中,root是一个文件夹target-&gt; dist-&gt; bundle,你可以得到你的新Setup.exe

PathToExe

带图标的安装程序

最后你明白了。

Installer

目标结构

目标文件夹包含来自maven运行的无效jar,但无关紧要。你应该知道,如果你只想通过双击启动jar,你需要选择dist文件夹中的那个。 dist文件夹中的jar是必不可少的,因为创建安装程序的整个过程依赖于这个jar。现在,您还可以将* .iss文件放在包的Windows文件夹中,以自定义创建过程的更多部分,如许可证文件等。为此,请查看Inno Setup的documention

TargetStructure

答案 1 :(得分:2)

对于已经使用Maven构建jar的人来说,使用javafx-maven-plugin可以轻松构建本机应用程序并包含图标。 (我是通过this answer找到的。)

插件开发人员提供了一个不错的小自动配置script。我不得不添加<vendor>键,但一切顺利。

一旦你有了这个工作,你需要做的就是创建一个正确格式的文件,给它提供与本机应用程序完全相同的名称,并将其放在给定系统的正确文件夹中:

  • Windows:在src / main / deploy / package / windows / {appname} .ico中放置一些ICO文件,其中{appname}是应用程序的已配置appname
  • Mac OS(X):在src / main / deploy / package / macosx / {appname} .icns中放置一些ICNS文件,其中{appname}是应用程序的已配置appname
  • Linux:将一些PNG文件放在src / main / deploy / package / linux / {appname} .png中,其中{appname}是应用程序的已配置appname

(上面的文字是从this issue复制的。)

我在Windows和Mac上都测试了这个,它在两种情况下都有效。

答案 2 :(得分:0)

您是否考虑过使用launch4j?我用它来创建我的exe文件,它可以完美地工作,并允许你设置图标。我将它与izpack结合使用。

答案 3 :(得分:0)

您需要将package文件夹放在根项目中。控制台的输出指示正确的路径。我知道这是个老问题,但可以帮助其他人。