这是我在JavaFX上的第一个项目。我正在使用eclipse将我的项目构建为exe文件。我快完了。但是我不知道我现在的问题是什么。
我的ant构建文件代码在这里。
<?xml version="1.0" encoding="UTF-8"?>
<project name="Feel Free" default="do-deploy" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant">
<target name="init-fx-tasks">
<path id="fxant">
<filelist>
<file name="C:Program FilesJavajdk1.8.0_66libant-javafx.jar"/>
<file name="C:Program FilesJavajdk1.8.0_66jrelibextjfxrt.jar"/>
<file name="${basedir}"/>
</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="C:Program FilesJavajdk1.8.0_66lib">
<filename name="java-json.jar"/>
</fileset>
</copy>
<mkdir dir="project" />
<copy todir="project">
<fileset dir="C:UsersBhuvaneshworkspaceFeel Free">
<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="java-json.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="Cp1252">
<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="Feel Free.jar"/>
<fx:fileset dir="dist" includes="libs/*"/>
<fx:fileset dir="dist" includes="resources/**"/>
</fx:resources>
<fx:application id="fxApplication"
name="Feel Free"
mainClass="application.Main"
version="1.0"
/>
<mkdir dir="build/classes/META-INF" />
<fx:jar destfile="dist/Feel Free.jar">
<fx:application refid="fxApplication"/>
<fileset dir="build/classes">
</fileset>
<fx:resources refid="appRes"/>
<manifest>
<attribute name="Implementation-Vendor" value="Bhuan Tech"/>
<attribute name="Implementation-Title" value="Feel Free"/>
<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="Feel Free" nativeBundles="exe"
updatemode="background" >
<fx:platform basedir="${java.home}"/>
<fx:info title="Feel Free" vendor="Bhuan Tech"/>
<fx:application refId="fxApplication"/>
<fx:resources refid="appRes"/>
</fx:deploy>
</target>
错误信息是:
Buildfile: C:UsersBhuvaneshworkspaceFeel Freebuildbuild.xml
setup-staging-area:
[delete] Deleting directory C:UsersBhuvaneshworkspaceFeel FreebuildexternalLibs
[delete] Deleting directory C:UsersBhuvaneshworkspaceFeel Freebuildproject
[delete] Deleting directory C:UsersBhuvaneshworkspaceFeel FreebuildprojectRefs
[mkdir] Created dir: C:UsersBhuvaneshworkspaceFeel FreebuildexternalLibs
[copy] Copying 1 file to C:UsersBhuvaneshworkspaceFeel FreebuildexternalLibs
[mkdir] Created dir: C:UsersBhuvaneshworkspaceFeel Freebuildproject
[copy] Copying 14 files to C:UsersBhuvaneshworkspaceFeel Freebuildproject
[mkdir] Created dir: C:UsersBhuvaneshworkspaceFeel FreebuildprojectRefs
do-compile:
[delete] Deleting directory C:UsersBhuvaneshworkspaceFeel Freebuildbuild
[mkdir] Created dir: C:UsersBhuvaneshworkspaceFeel Freebuildbuildsrc
[mkdir] Created dir: C:UsersBhuvaneshworkspaceFeel Freebuildbuildlibs
[mkdir] Created dir: C:UsersBhuvaneshworkspaceFeel Freebuildbuildclasses
[copy] Copying 1 file to C:UsersBhuvaneshworkspaceFeel Freebuildbuildlibs
[copy] Copying 14 files to C:UsersBhuvaneshworkspaceFeel Freebuildbuildsrc
[javac] Compiling 3 source files to C:UsersBhuvaneshworkspaceFeel Freebuildbuildclasses
[copy] Copying 11 files to C:UsersBhuvaneshworkspaceFeel Freebuildbuildclasses
init-fx-tasks:
do-deploy:
[copy] Copying 1 file to C:UsersBhuvaneshworkspaceFeel Freebuilddistlibs
[mkdir] Created dir: C:UsersBhuvaneshworkspaceFeel FreebuildbuildclassesMETA-INF
BUILD FAILED
C:UsersBhuvaneshworkspaceFeel Freebuildbuild.xml:131: Can not find JDK artifacts in specified location: C:Program FilesJavajre1.8.0_66
Total time: 2 seconds
告诉eclipse使用JDK而不是JRE,因为JRE没有所有库jar文件。
在Eclipse中,选择"窗口"菜单->"首选项"。然后选择Java->Installed JRE。然后单击添加…选择标准VM,然后单击下一步。在JRE主页中,导航到JDK安装到的文件夹(c:\Program Files\Java\jdk1.6.0_21)。
参考:链接
尝试设置JAVA_HOME环境变量。