【问题标题】:Deploy my javafx 2 application on eclipse-SDK-4.2.1-win32-efx-0.8.0在 eclipse-SDK-4.2.1-win32-efx-0.8.0 上部署我的 javafx 2 应用程序
【发布时间】:2013-05-17 08:24:28
【问题描述】:

我为 javafx 开发安装了 eclipse-SDK-4.2.1-win32-efx-0.8.0。 我进行了 soe 测试,我想部署我的应用程序。 我首先将它导出到 ant 并在我的项目中得到这个 ant 文件

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- WARNING: Eclipse auto-generated file.
              Any modifications will be overwritten.
              To include a user specific buildfile here, simply create one in the same
              directory with the processing instruction <?eclipse.ant.import?>
              as the first entry and export the buildfile again. --><project basedir="." default="build" name="Newtest">
    <property environment="env"/>
    <property name="ECLIPSE_HOME" value="../../"/>
    <property name="debuglevel" value="source,lines,vars"/>
    <property name="target" value="1.7"/>
    <property name="source" value="1.7"/>
    <path id="JavaFX SDK.libraryclasspath">
        <pathelement location="C:/Program Files/Java/jre7/lib/jfxrt.jar"/>
    </path>
    <path id="Newtest.classpath">
        <pathelement location="bin"/>
        <path refid="JavaFX SDK.libraryclasspath"/>
        <pathelement location="lib/jfxtras-labs-2.2-r4.jar"/>
    </path>
    <target name="init">
        <mkdir dir="bin"/>
        <copy includeemptydirs="false" todir="bin">
            <fileset dir="src">
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
    </target>
    <target name="clean">
        <delete dir="bin"/>
    </target>
    <target depends="clean" name="cleanall"/>
    <target depends="build-subprojects,build-project" name="build"/>
    <target name="build-subprojects"/>
    <target depends="init" name="build-project">
        <echo message="${ant.project.name}: ${ant.file}"/>
        <javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}">
            <src path="src"/>
            <classpath refid="Newtest.classpath"/>
        </javac>
    </target>
    <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
    <target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
        <copy todir="${ant.library.dir}">
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </copy>
        <unzip dest="${ant.library.dir}">
            <patternset includes="jdtCompilerAdapter.jar"/>
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </unzip>
    </target>
    <target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
        <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
        <antcall target="build"/>
    </target>
    <target name="Test">
        <java classname="app.TEst" failonerror="true" fork="yes">
            <classpath refid="Newtest.classpath"/>
        </java>
    </target>
</project>

然后点击“ 生成 ant build.xml 并运行”我在控制台上有这个错误:

Buildfile: D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\build.xml
setup-staging-area:
   [delete] Deleting directory D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\externalLibs
   [delete] Deleting directory D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\project
   [delete] Deleting directory D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\projectRefs
    [mkdir] Created dir: D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\externalLibs
     [copy] Copying 1 file to D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\externalLibs
    [mkdir] Created dir: D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\project
     [copy] Copying 2 files to D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\project
    [mkdir] Created dir: D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\projectRefs
do-compile:
   [delete] Deleting directory D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\build
    [mkdir] Created dir: D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\build\src
    [mkdir] Created dir: D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\build\libs
    [mkdir] Created dir: D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\build\classes
     [copy] Copying 1 file to D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\build\libs
     [copy] Copying 2 files to D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\build\src
    [javac] Compiling 2 source files to D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\build\classes
init-fx-tasks:
  [taskdef] Could not load definitions from resource com/sun/javafx/tools/ant/antlib.xml. It could not be found.
do-deploy:
     [copy] Copying 1 file to D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\dist\libs

BUILD FAILED
D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\build.xml:93: Problem: failed to create task or type javafx:com.sun.javafx.tools.ant:resources
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
No types or tasks have been defined in this namespace yet


Total time: 14 seconds

我对蚂蚁一无所知,请问我的问题是什么? 谢谢

【问题讨论】:

    标签: deployment ant javafx-2


    【解决方案1】:

    所以它告诉你它无法加载 JavaFX ant 扩展

    无法从资源加载定义 com/sun/javafx/tools/ant/antlib.xml。找不到。部署:

    为什么不使用 build.fxbuild 文件生成 ANT 文件?

    【讨论】:

      【解决方案2】:

      这是我项目中的另一个 ant 文件:

      <?xml version="1.0" encoding="UTF-8"?>
          <project name="Newtest" 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="D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\lib">
                      <filename name="jfxtras-labs-2.2-r4.jar"/>  
                  </fileset>
              </copy>
              <copy todir="externalLibs">
                  <fileset dir="D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\lib">
                      <filename name="ant-javafx.jar"/>   
                  </fileset>
              </copy>
      
              <mkdir dir="project" />
              <copy todir="project">
                  <fileset dir="D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest">
                      <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="ant-javafx.jar"/>
                      <include name="jfxtras-labs-2.2-r4.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.7" target="1.7" srcdir="build/src" destdir="build/classes" encoding="Cp1252">
                  <classpath>
                      <fileset dir="build/libs">
                          <include name="*"/>
                      </fileset>
                      <filelist>
                          <file name="C:\Program Files\Java\jre7\lib\jfxrt.jar"/>
                      </filelist>
                  </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="Newtest.jar"/>
                  <fx:fileset dir="dist" includes="libs/*"/>
              </fx:resources> 
      
              <fx:application id="fxApplication"
                  name="Newtest"
                  mainClass="app.TEst"
              />
      
              <mkdir dir="build/classes/META-INF" />
      
      
      
              <fx:jar destfile="dist/Newtest.jar">
                  <fx:application refid="fxApplication"/>
                  <fileset dir="build/classes">
                  </fileset>
                  <fx:resources refid="appRes"/>
      
                  <manifest>
                      <attribute name="Implementation-Vendor" value="Menguelenium"/>
                      <attribute name="Implementation-Title" value=""/>
                      <attribute name="Implementation-Version" value="0.0"/>
                  </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"
                  width="400" height="350" 
                  includeDT="false"
                  offlineAllowed="true"
                  outdir="${basedir}/deploy"
                  outfile="Newtest" 
                  updatemode="background" >
      
                  <fx:info title="Newtest" vendor="Menguelenium"/>
                  <fx:application refId="fxApplication"/>
                  <fx:resources refid="appRes"/>
              </fx:deploy>
      
      
          </target>
      </project>
      

      拜托我真的很熟悉蚂蚁。这是我第一次使用它。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-02-22
        • 1970-01-01
        • 2022-07-13
        • 1970-01-01
        • 2012-12-18
        • 1970-01-01
        • 2018-05-18
        • 2010-12-27
        相关资源
        最近更新 更多