当前位置: 首页 > 知识库问答 >
问题:

在Eclipse中创建JavaFX自包含应用程序(使用自定义JDK)

葛念
2023-03-14
<target name="-post-jfx-deploy">
   <fx:deploy width="${javafx.run.width}" height="${javafx.run.height}" 
             nativeBundles="all"
             outdir="${basedir}/${dist.dir}" outfile="${application.title}">
      <fx:application name="${application.title}" mainClass="${javafx.main.class}"/>
      <fx:resources>
          <fx:fileset dir="${basedir}/${dist.dir}" includes="BrickBreaker.jar"/>
      </fx:resources>
      <fx:info title="${application.title}" vendor="${application.vendor}"/>
    </fx:deploy>          
 </target>
Buildfile: /Users/RobinTrietsch/EclipseProjects/octocash-updater/OctoCash Updater/build/build.xml
setup-staging-area:
   [delete] Deleting directory /Users/RobinTrietsch/EclipseProjects/octocash-updater/OctoCash Updater/build/externalLibs
   [delete] Deleting directory /Users/RobinTrietsch/EclipseProjects/octocash-updater/OctoCash Updater/build/project
   [delete] Deleting directory /Users/RobinTrietsch/EclipseProjects/octocash-updater/OctoCash Updater/build/projectRefs
    [mkdir] Created dir: /Users/RobinTrietsch/EclipseProjects/octocash-updater/OctoCash Updater/build/externalLibs
     [copy] Copying 1 file to /Users/RobinTrietsch/EclipseProjects/octocash-updater/OctoCash Updater/build/externalLibs
    [mkdir] Created dir: /Users/RobinTrietsch/EclipseProjects/octocash-updater/OctoCash Updater/build/project
     [copy] Copying 4 files to /Users/RobinTrietsch/EclipseProjects/octocash-updater/OctoCash Updater/build/project
    [mkdir] Created dir: /Users/RobinTrietsch/EclipseProjects/octocash-updater/OctoCash Updater/build/projectRefs
do-compile:
   [delete] Deleting directory /Users/RobinTrietsch/EclipseProjects/octocash-updater/OctoCash Updater/build/build
    [mkdir] Created dir: /Users/RobinTrietsch/EclipseProjects/octocash-updater/OctoCash Updater/build/build/src
    [mkdir] Created dir: /Users/RobinTrietsch/EclipseProjects/octocash-updater/OctoCash Updater/build/build/libs
    [mkdir] Created dir: /Users/RobinTrietsch/EclipseProjects/octocash-updater/OctoCash Updater/build/build/classes
     [copy] Copying 1 file to /Users/RobinTrietsch/EclipseProjects/octocash-updater/OctoCash Updater/build/build/libs
     [copy] Copying 4 files to /Users/RobinTrietsch/EclipseProjects/octocash-updater/OctoCash Updater/build/build/src
    [javac] Compiling 1 source file to /Users/RobinTrietsch/EclipseProjects/octocash-updater/OctoCash Updater/build/build/classes
     [copy] Copying 3 files to /Users/RobinTrietsch/EclipseProjects/octocash-updater/OctoCash Updater/build/build/classes
init-fx-tasks:
do-deploy:
     [copy] Copying 1 file to /Users/RobinTrietsch/EclipseProjects/octocash-updater/OctoCash Updater/build/dist/libs
    [mkdir] Created dir: /Users/RobinTrietsch/EclipseProjects/octocash-updater/OctoCash Updater/build/build/classes/META-INF
No base JDK. Package will use system JRE.
Bundler Mac Application Image skipped because of a configuration problem: Main application jar is missing.  
Advice to fix: Make sure to use fx:jar task to create main application jar.
Bundler DMG Installer skipped because of a configuration problem: Main application jar is missing.  
Advice to fix: Make sure to use fx:jar task to create main application jar.
Bundler PKG Installer skipped because of a configuration problem: Main application jar is missing.  
Advice to fix: Make sure to use fx:jar task to create main application jar.
Bundler Mac App Store Ready Bundler skipped because of a configuration problem: Main application jar is missing.  
Advice to fix: Make sure to use fx:jar task to create main application jar.
BUILD SUCCESSFUL
Total time: 2 seconds
<?xml version="1.0" encoding="UTF-8"?>
<project name="OctoCash Updater" default="do-deploy" basedir="."  xmlns:fx="javafx:com.sun.javafx.tools.ant">
<target name="init-fx-tasks">
    <path id="fxant">
        <filelist>
            <file name="${java.home}\..\lib\ant-javafx.jar"/>
            <file name="${java.home}\lib\jfxrt.jar"/>
        </filelist>
    </path>

    <taskdef resource="com/sun/javafx/tools/ant/antlib.xml"      
        uri="javafx:com.sun.javafx.tools.ant"
        classpathref="fxant"/>
</target>
<target name="setup-staging-area">
    <delete dir="externalLibs" />
    <delete dir="project" />
    <delete dir="projectRefs" />

    <mkdir dir="externalLibs" />

    <copy todir="externalLibs">
        <fileset dir="/Users/RobinTrietsch/EclipseProjects/octocash-updater/OctoCash Updater/lib">
            <filename name="gson-2.3.1.jar"/>   
        </fileset>
    </copy>

    <mkdir dir="project" />
    <copy todir="project">
        <fileset dir="/Users/RobinTrietsch/EclipseProjects/octocash-updater/OctoCash Updater">
            <include name="src/**" />
        </fileset>
    </copy>

    <mkdir dir="projectRefs" />
</target>
<target name='do-compile'>
    <delete dir="build" />
    <mkdir dir="build/src" />
    <mkdir dir="build/libs" />
    <mkdir dir="build/classes" />

    <!-- Copy project-libs references -->
    <copy todir="build/libs">
        <fileset dir="externalLibs">
            <include name="gson-2.3.1.jar"/>
        </fileset>
    </copy>

    <!-- Copy project references -->

    <!-- Copy project sources itself -->
    <copy todir="build/src">
        <fileset dir="project/src">
            <include name="**/*"/>
        </fileset>
    </copy>

    <javac includeantruntime="false" source="1.8" target="1.8" srcdir="build/src" destdir="build/classes" encoding="UTF-8">
        <classpath>
            <fileset dir="build/libs">
                <include name="*"/>
            </fileset>
        </classpath>
    </javac>

    <!-- Copy over none Java-Files -->
    <copy todir="build/classes">
    <fileset dir="project/src">
        <exclude name="**/*.java"/>
    </fileset>
    </copy>


</target>
<target name="do-deploy" depends="setup-staging-area, do-compile, init-fx-tasks">
    <delete file="dist"/>
    <delete file="deploy" />

    <mkdir dir="dist" />
    <mkdir dir="dist/libs" />

    <copy todir="dist/libs">
        <fileset dir="externalLibs">
            <include name="*" />
        </fileset>
    </copy>


    <fx:resources id="appRes">
        <fx:fileset dir="dist" includes="OctoCash Updater.jar"/>
        <fx:fileset dir="dist" includes="libs/*"/>
    </fx:resources> 

    <fx:application id="fxApplication"
        name="OctoCash"
        mainClass="octocash.updater.Main"
        toolkit="fx"
    />

    <mkdir dir="build/classes/META-INF" />



    <fx:jar destfile="dist/OctoCash Updater.jar">
        <fx:application refid="fxApplication"/>
        <fileset dir="build/classes">
        </fileset>
        <fx:resources refid="appRes"/>

        <manifest>
            <attribute name="Implementation-Vendor" value="Barotech"/>
            <attribute name="Implementation-Title" value="OctoCash"/>
            <attribute name="Implementation-Version" value="1.0"/>
            <attribute name="JavaFX-Feature-Proxy" value="None"/>
        </manifest>
    </fx:jar>


    <mkdir dir="deploy" />
    <!-- Need to use ${basedir} because somehow the ant task is calculating the directory differently -->
    <fx:deploy
        embedJNLP="false"
        extension="false"
        includeDT="false"
        offlineAllowed="true"
        outdir="${basedir}/deploy"
        outfile="OctoCash Updater" nativeBundles="all"
        updatemode="background" >

        <fx:info title="OctoCash Updater" vendor="Barotech"/>
        <fx:application refId="fxApplication"/>
        <fx:resources refid="appRes"/>
    </fx:deploy>


</target>

共有1个答案

秦经义
2023-03-14

这是一个老问题,但我只是有这个问题。我好不容易才找到解决办法。通过阅读大量不同的材料,我设法找到了解决办法。我使用Netbeans,但它应该适用于Eclipse。

在Netbeans中,我浏览了项目中的文件,直到找到一个名为project.properties的文件。然后打开文件,转到以dist.jar=开头的行。接下来,我重命名jar文件,使其具有与项目主文件完全相同的名称。

在我的例子中,我的主要名称类似于helloworld,我的dist.jar名称为hello world.jar,我将其重命名为helloworld.jar并保存了文件。然后我重新构建了项目并重新创建了本机安装程序。之后效果很好。

 类似资料:
  • 我已经和这件事斗争了一天多,在SO和其他地方读了很多帖子,但我仍然有问题。 我需要在一个自包含的JavaFX应用程序包中包含我的应用程序图标。我使用的是JDK1.8.0_45及其包含的JavaFX包。我正在使用Maven构建.exe,除了我不能包含我的图标外,它都运行得很好。 下面是我的pom.xml: 使图标出现在标题栏中的是javapackager部署步骤的参数。这一行告诉inno安装程序使用

  • 基本上,我想知道我是否可以创建一个树并在JavaFX上自定义它...我试着去做,但到目前为止还不能用这个代码做任何事情... 我在质疑自己,这是否是正确的“技术”,可以解决我想做的事情... 我从https://docs.oracle.com/javafx/2/ui_controls/tree-view.htm#babjgggf看到了这个教程,但我对这个教程真的很困惑...我不太了解细胞工厂的机制

  • 按照这里和这里的指示。我使用的是JDK7U9和NetBeans 7.2.1。我所做的是创建相对于我的项目根文件夹的整个路径(C:\users\administrator\desktop\icotest\package\windows\icotest.ico)。我同时尝试了48x48和256x256的大小。下面是我的项目Icotest的树状结构概述: 这就是build.xml的样子:

  • 转换为fxml 我总是从javafx.fxml.loadException类型中得到错误代码:也许有比创建自定义类更好的解决方案。但我需要一个标签与自定义接口(连接)。也许另一个解决方案是创建一个只包含标签的fxml文件,并通过接口为此设置一个控制器类。 编辑:

  • 为了完整起见,我使用Oracle JDK 1.8.0_66 for Mac。

  • 我正在编写一个Spring Boot应用程序,它与Snowflake数据仓库连接,并对其执行SQL查询。我编写了一个配置类,用于配置数据源以连接到Snowflake数据仓库,如下所示: 我的pom.xml如下: 在我的Spring boot应用程序中,我必须为这个数据源使用一个连接池。 如何在我的应用程序中使用HikariCP连接池,它可以与我的定制数据源完美配合? ------编辑---感谢您提