2013-02-17 1 views
0

Я пытаюсь построить свой файл банку с зависимостями с помощью этого build.xml (NetBeans):Получение файла банку с зависимостями от проекта JavaFX

<?xml version="1.0" encoding="UTF-8"?><!-- You may freely edit this file. See commented blocks below for --><!-- some examples of how to customize the build. --><!-- (If you delete it and reopen the project it will be recreated.) --><!-- By default, only the Clean and Build commands use this build script. --><project name="TargetAppDesktop" default="default" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant"> 
    <description>Builds, tests, and runs the project TargetAppDesktop.</description> 
    <import file="nbproject/build-impl.xml"/> 
    <!-- 

    There exist several targets which are by default empty and which can be 
    used for execution of your tasks. These targets are usually executed 
    before and after some main targets. Those of them relevant for JavaFX project are: 

     -pre-init:     called before initialization of project properties 
     -post-init:    called after initialization of project properties 
     -pre-compile:    called before javac compilation 
     -post-compile:    called after javac compilation 
     -pre-compile-test:   called before javac compilation of JUnit tests 
     -post-compile-test:  called after javac compilation of JUnit tests 
     -pre-jfx-jar:    called before FX SDK specific <fx:jar> task 
     -post-jfx-jar:    called after FX SDK specific <fx:jar> task 
     -pre-jfx-deploy:   called before FX SDK specific <fx:deploy> task 
     -post-jfx-deploy:   called after FX SDK specific <fx:deploy> task 
     -post-clean:    called after cleaning build products 

    (Targets beginning with '-' are not intended to be called on their own.) 

    Example of inserting a HTML postprocessor after javaFX SDK deployment: 

     <target name="-post-jfx-deploy"> 
      <basename property="jfx.deployment.base" file="${jfx.deployment.jar}" suffix=".jar"/> 
      <property name="jfx.deployment.html" location="${jfx.deployment.dir}${file.separator}${jfx.deployment.base}.html"/> 
      <custompostprocess> 
       <fileset dir="${jfx.deployment.html}"/> 
      </custompostprocess> 
     </target> 

    Example of calling an Ant task from JavaFX SDK. Note that access to JavaFX SDK Ant tasks must be 
    initialized; to ensure this is done add the dependence on -check-jfx-sdk-version target: 

     <target name="-post-jfx-jar" depends="-check-jfx-sdk-version"> 
      <echo message="Calling jar task from JavaFX SDK"/> 
      <fx:jar ...> 
       ... 
      </fx:jar> 
     </target> 

    For more details about JavaFX SDK Ant tasks go to 
    http://docs.oracle.com/javafx/2/deployment/jfxpub-deployment.htm 

    For list of available properties check the files 
    nbproject/build-impl.xml and nbproject/jfx-impl.xml. 

    --> 

<!-- Para gerar um arquivo unico adicionar as linhas abaixo --> 

    <target name="package-for-store" depends="jar"> 

     <!-- Change the value of this property to be the name of your JAR, 
      minus the .jar extension. It should not have spaces. 
      <property name="store.jar.name" value="MyJarName"/> 
     --> 
     <property name="store.jar.name" value="TargetAppDesktop"/> 


     <!-- don't edit below this line --> 

     <property name="store.dir" value="store"/> 
     <property name="store.jar" value="${store.dir}/${store.jar.name}.jar"/> 

     <echo message="Packaging ${application.title} into a single JAR at ${store.jar}"/> 

     <delete dir="${store.dir}"/> 
     <mkdir dir="${store.dir}"/> 

     <jar destfile="${store.dir}/temp_final.jar" filesetmanifest="skip"> 
      <zipgroupfileset dir="dist" includes="*.jar"/> 
      <zipgroupfileset dir="dist/lib" includes="*.jar"/> 

      <manifest> 
       <attribute name="Main-Class" value="${main.class}"/> 
      </manifest> 
     </jar> 

     <zip destfile="${store.jar}"> 
      <zipfileset src="${store.dir}/temp_final.jar" 
      excludes="META-INF/*.SF, META-INF/*.DSA, META-INF/*.RSA"/> 
     </zip> 

     <delete file="${store.dir}/temp_final.jar"/> 

    </target> 


    <!--> Fim do codigo para arquivo unico --> 
</project> 

Когда я строю это все, кажется, будет хорошо, но когда Я пытаюсь открыть файл jar. Я получаю сообщение об ошибке с запуска программы javaFX:

Невозможно найти имя класса приложения.

Кто-нибудь знает, что происходит? Или более простой способ получить эту банку?

+0

У вас есть класс, который расширяет приложение? –

+0

Да, конечно. –

+1

Вы посмотрели на это? http://netbeans.org/bugzilla/show_bug.cgi?id=213205 –

ответ

0

Вам нужно будет немного изменить манифест. Из того, что у вас есть:

<manifest> 
    <attribute name="Main-Class" value="${main.class}"/> 
</manifest> 

Чтобы что-то похожее на:

<manifest> 
       <attribute name="Main-Class" value="${main.class}"/> 
<!-- your javaFX version --> 
       <attribute name="JavaFX-Version" value="2.2"/> 
<!-- your main class --> 
       <attribute name="JavaFX-Application-Class" value="package.MainClass"/> 
<!-- your javaFx build path --> 
       <attribute name="JavaFX-Class-Path" value="lib/Program.jar lib/Utils.jar lib/commons-codec-1.5 
    .jar lib/commons-logging-1.1.jar lib/dom4j-1.6.1.jar lib/junit-4.10.j 
    ar lib/poi-3.10-FINAL-20140208.jar lib/poi-excelant-3.10-FINAL-201402 
    08.jar lib/poi-ooxml-3.10-FINAL-20140208.jar lib/poi-ooxml-schemas-3. 
    10-FINAL-20140208.jar lib/poi-scratchpad-3.10-FINAL-20140208.jar lib/ 
    stax-api-1.0.1.jar lib/xmlbeans-2.3.0.jar"/> 
      <attribute name="Permissions" value="sandbox"/> 

    </manifest> 

Я лично использовал один выше, и она работала, но как вы можете видеть, что есть вещи, которые являются уникальными для моего проекта. Самый простой способ получить ваш путь и версию javaFX - открыть банку в папке dist с помощью 7zip или аналогичной программы и посмотреть, что находится в манифесте для этих полей.