这是我在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 Files\Java\jdk1.8.0_66\lib\ant-javafx.jar"/>
<file name="C:\Program Files\Java\jdk1.8.0_66\jre\lib\ext\jfxrt.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 Files\Java\jdk1.8.0_66\lib">
<filename name="java-json.jar"/>
</fileset>
</copy>
<mkdir dir="project" />
<copy todir="project">
<fileset dir="C:\Users\Bhuvanesh\workspace\Feel 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:\Users\Bhuvanesh\workspace\Feel Free\build\build.xml
setup-staging-area:
[delete] Deleting directory C:\Users\Bhuvanesh\workspace\Feel Free\build\externalLibs
[delete] Deleting directory C:\Users\Bhuvanesh\workspace\Feel Free\build\project
[delete] Deleting directory C:\Users\Bhuvanesh\workspace\Feel Free\build\projectRefs
[mkdir] Created dir: C:\Users\Bhuvanesh\workspace\Feel Free\build\externalLibs
[copy] Copying 1 file to C:\Users\Bhuvanesh\workspace\Feel Free\build\externalLibs
[mkdir] Created dir: C:\Users\Bhuvanesh\workspace\Feel Free\build\project
[copy] Copying 14 files to C:\Users\Bhuvanesh\workspace\Feel Free\build\project
[mkdir] Created dir: C:\Users\Bhuvanesh\workspace\Feel Free\build\projectRefs
do-compile:
[delete] Deleting directory C:\Users\Bhuvanesh\workspace\Feel Free\build\build
[mkdir] Created dir: C:\Users\Bhuvanesh\workspace\Feel Free\build\build\src
[mkdir] Created dir: C:\Users\Bhuvanesh\workspace\Feel Free\build\build\libs
[mkdir] Created dir: C:\Users\Bhuvanesh\workspace\Feel Free\build\build\classes
[copy] Copying 1 file to C:\Users\Bhuvanesh\workspace\Feel Free\build\build\libs
[copy] Copying 14 files to C:\Users\Bhuvanesh\workspace\Feel Free\build\build\src
[javac] Compiling 3 source files to C:\Users\Bhuvanesh\workspace\Feel Free\build\build\classes
[copy] Copying 11 files to C:\Users\Bhuvanesh\workspace\Feel Free\build\build\classes
init-fx-tasks:
do-deploy:
[copy] Copying 1 file to C:\Users\Bhuvanesh\workspace\Feel Free\build\dist\libs
[mkdir] Created dir: C:\Users\Bhuvanesh\workspace\Feel Free\build\build\classes\META-INF
BUILD FAILED
C:\Users\Bhuvanesh\workspace\Feel Free\build\build.xml:131: Can not find JDK artifacts in specified location: C:\Program Files\Java\jre1.8.0_66
Total time: 2 seconds
答案 0 :(得分:2)
告诉eclipse使用JRE的JDK,因为jre没有所有的库jar文件。
在Eclipse中,选择Window菜单 - &gt; Preferences。然后选择Java-&gt; Installed JRE。然后单击Add ...选择Standard VM,然后单击Next。在JRE主目录中,导航到已安装JDK的文件夹(c:\ Program Files \ Java \ jdk1.6.0_21)。
参考:link
答案 1 :(得分:1)
尝试设置JAVA_HOME env变量。