在Eclipse中创建JavaFX自包含应用程序(使用自定义JDK)
正如标题所示,我想使用系统默认设置以外的其他JDK/JRE创建一个自包含的JavaFX应用程序。Netbeans能够做到这一点,但是,我还不知道如何在Eclipse中做到这一点 通过使用,您可以生成生成文件(在Eclipse中创建JavaFX自包含应用程序(使用自定义JDK),java,eclipse,javafx,Java,Eclipse,Javafx,正如标题所示,我想使用系统默认设置以外的其他JDK/JRE创建一个自包含的JavaFX应用程序。Netbeans能够做到这一点,但是,我还不知道如何在Eclipse中做到这一点 通过使用,您可以生成生成文件(build.fxbuild)。对于Netbeans,需要将以下内容添加到build.xml中,以便在jar中包含自定义JDK(这只是来自的示例): 编辑:添加生成的build.xml <?xml version="1.0" encoding="UTF-8"?> <proje
build.fxbuild
)。对于Netbeans,需要将以下内容添加到build.xml
中,以便在jar中包含自定义JDK(这只是来自的示例):
编辑:添加生成的build.xml
<?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>
您选择了什么作为包装格式?如果选择“全部”,它将生成一个包含JRE的独立安装程序。这是一个老问题,但我刚刚遇到了这个问题。我很难找到解决办法。通过阅读大量不同的资料,我设法找到了解决办法。我使用Netbeans,但它应该适用于Eclipse 在Netbeans中,我浏览了项目中的文件,直到找到一个名为project.properties的文件。然后我打开文件并转到以dist.jar=开头的行。接下来,我重命名jar文件,使其与我的项目主文件具有完全相同的名称
在我的例子中,我的主名称是helloworld,dist.jar是hello world.jar,我将其重命名为helloworld.jar并保存了文件。然后,我重建了项目并重新创建了本机安装程序。之后效果很好。谢谢您的回复!我已经选择了选项'all',但我仍然在控制台中得到相同的消息:“没有基本JDK。包将使用系统JRE。”然后是“确保使用fx:jar任务来创建主应用程序jar。”。有什么想法吗?那么它会在这个消息之后停止吗?我在OS-X上也获得了JDK信息。如果您在某处共享了一个示例,我会看一看。我已经从控制台添加了输出。显示此消息后,它不会停止,但它也不会在jar中包含JRE。创建了一个可运行的jar,但是它使用系统JRE。谢谢你看!我已经在问题的底部添加了build.xml,这不是一个很疯狂的猜测,但它可能是“dist/OctoCash Updater.jar”中的空格吗?如果这没有帮助,请针对efxclipse提交一个bug,我们将解决这个问题。
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>