草庐IT

java - 在独立的 JavaFX 应用程序中包含图标

coder 2024-03-16 原文

我已经为此奋斗了一天多,并且阅读了很多关于 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:这是我的文件资源管理器的屏幕截图:

编辑 2:这是展开的目标文件夹的屏幕截图:

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

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 中描述的“插入资源” , 但无论我如何尝试使类路径正确,它都无法识别我的自定义图标

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

这是我当前的 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 安装程序使用该图标。最后一个难题是如何让 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

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

最佳答案

先决条件/假设

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

解决方案

项目结构

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

pom.xml

正确部署还需要一些其他属性。正如您在 antrun 插件部分中看到的,您需要在调用构建文件之前为您的 ant 环境重新分配属性。属性会自动设置为调用的构建文件。通常 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

我已尝试使其松散耦合,因此通常无需更改该文件中的任何内容。仅当您想要签名或特殊行为等时。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。上述尺寸。

我的图片看起来像这样:

运行配置

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

应用

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

exe安装程序路径

在您的项目根目录中有一个文件夹 target->dist->bundles,在那里您可以获得新的 Setup.exe

带图标的安装程序

终于明白了。

目标结构

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

关于java - 在独立的 JavaFX 应用程序中包含图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31298015/

有关java - 在独立的 JavaFX 应用程序中包含图标的更多相关文章

  1. ruby - 在 Ruby 程序执行时阻止 Windows 7 PC 进入休眠状态 - 2

    我需要在客户计算机上运行Ruby应用程序。通常需要几天才能完成(复制大备份文件)。问题是如果启用sleep,它会中断应用程序。否则,计算机将持续运行数周,直到我下次访问为止。有什么方法可以防止执行期间休眠并让Windows在执行后休眠吗?欢迎任何疯狂的想法;-) 最佳答案 Here建议使用SetThreadExecutionStateWinAPI函数,使应用程序能够通知系统它正在使用中,从而防止系统在应用程序运行时进入休眠状态或关闭显示。像这样的东西:require'Win32API'ES_AWAYMODE_REQUIRED=0x0

  2. ruby - 将差异补丁应用于字符串/文件 - 2

    对于具有离线功能的智能手机应用程序,我正在为Xml文件创建单向文本同步。我希望我的服务器将增量/差异(例如GNU差异补丁)发送到目标设备。这是计划:Time=0Server:hasversion_1ofXmlfile(~800kiB)Client:hasversion_1ofXmlfile(~800kiB)Time=1Server:hasversion_1andversion_2ofXmlfile(each~800kiB)computesdeltaoftheseversions(=patch)(~10kiB)sendspatchtoClient(~10kiBtransferred)Cl

  3. ruby - 如何指定 Rack 处理程序 - 2

    Rackup通过Rack的默认处理程序成功运行任何Rack应用程序。例如:classRackAppdefcall(environment)['200',{'Content-Type'=>'text/html'},["Helloworld"]]endendrunRackApp.new但是当最后一行更改为使用Rack的内置CGI处理程序时,rackup给出“NoMethodErrorat/undefinedmethod`call'fornil:NilClass”:Rack::Handler::CGI.runRackApp.newRack的其他内置处理程序也提出了同样的反对意见。例如Rack

  4. ruby - 在 Ruby 中编写命令行实用程序 - 2

    我想用ruby​​编写一个小的命令行实用程序并将其作为gem分发。我知道安装后,Guard、Sass和Thor等某些gem可以从命令行自行运行。为了让gem像二进制文件一样可用,我需要在我的gemspec中指定什么。 最佳答案 Gem::Specification.newdo|s|...s.executable='name_of_executable'...endhttp://docs.rubygems.org/read/chapter/20 关于ruby-在Ruby中编写命令行实用程序

  5. ruby-on-rails - Rails 应用程序之间的通信 - 2

    我构建了两个需要相互通信和发送文件的Rails应用程序。例如,一个Rails应用程序会发送请求以查看其他应用程序数据库中的表。然后另一个应用程序将呈现该表的json并将其发回。我还希望一个应用程序将存储在其公共(public)目录中的文本文件发送到另一个应用程序的公共(public)目录。我从来没有做过这样的事情,所以我什至不知道从哪里开始。任何帮助,将不胜感激。谢谢! 最佳答案 无论Rails是什么,几乎所有Web应用程序都有您的要求,大多数现代Web应用程序都需要相互通信。但是有一个小小的理解需要你坚持下去,网站不应直接访问彼此

  6. ruby - 无法运行 Rails 2.x 应用程序 - 2

    我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby​​:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r

  7. ruby-on-rails - Rails 应用程序中的 Rails : How are you using application_controller. rb 是新手吗? - 2

    刚入门rails,开始慢慢理解。有人可以解释或给我一些关于在application_controller中编码的好处或时间和原因的想法吗?有哪些用例。您如何为Rails应用程序使用应用程序Controller?我不想在那里放太多代码,因为据我了解,每个请求都会调用此Controller。这是真的? 最佳答案 ApplicationController实际上是您应用程序中的每个其他Controller都将从中继承的类(尽管这不是强制性的)。我同意不要用太多代码弄乱它并保持干净整洁的态度,尽管在某些情况下ApplicationContr

  8. ruby-on-rails - 独立 ruby​​ 脚本的配置文件 - 2

    我有一个在Linux服务器上运行的ruby​​脚本。它不使用rails或任何东西。它基本上是一个命令行ruby​​脚本,可以像这样传递参数:./ruby_script.rbarg1arg2如何将参数抽象到配置文件(例如yaml文件或其他文件)中?您能否举例说明如何做到这一点?提前谢谢你。 最佳答案 首先,您可以运行一个写入YAML配置文件的独立脚本:require"yaml"File.write("path_to_yaml_file",[arg1,arg2].to_yaml)然后,在您的应用中阅读它:require"yaml"arg

  9. java - 等价于 Java 中的 Ruby Hash - 2

    我真的很习惯使用Ruby编写以下代码:my_hash={}my_hash['test']=1Java中对应的数据结构是什么? 最佳答案 HashMapmap=newHashMap();map.put("test",1);我假设? 关于java-等价于Java中的RubyHash,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22737685/

  10. ruby-on-rails - 如何在我的 Rails 应用程序 View 中打印 ruby​​ 变量的内容? - 2

    我是一个Rails初学者,但我想从我的RailsView(html.haml文件)中查看Ruby变量的内容。我试图在ruby​​中打印出变量(认为它会在终端中出现),但没有得到任何结果。有什么建议吗?我知道Rails调试器,但更喜欢使用inspect来打印我的变量。 最佳答案 您可以在View中使用puts方法将信息输出到服务器控制台。您应该能够在View中的任何位置使用Haml执行以下操作:-puts@my_variable.inspect 关于ruby-on-rails-如何在我的R

随机推荐