0

このbuild.xml(NetBeans)を使用して、依存関係のあるjarファイルをビルドしようとしています。

<?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ランチャーからエラーメッセージが表示されます。

アプリケーションクラス名が見つかりません。

誰かが何が起こっているのか知っていますか?または、この瓶を入手する簡単な方法はありますか?

4

1 に答える 1

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 フォルダー内の jar を 7zip または同様のプログラムで開き、これらのフィールドのマニフェストの内容を確認することです。

于 2014-11-17T20:47:52.760 に答える