Eclipse で JavaFX アプリケーションを開発しています。アプリには log4j などの外部ライブラリがあり、Eclipse から完全に実行されます。Eclipse の組み込み機能を使用して Eclipse から Runnable jar としてデプロイしようとしましたが、一部のコンピューターではうまく動作しますが、他のコンピューターではあいまいな未定義のリンク エラーが発生します。調べてみると、ANTスクリプトまたはjavafxpackager
アプリケーションを介してJavaFXを特別にパッケージ化する必要があるようです。
私の人生では、これらの方法のいずれかを介して実行可能な jar をデプロイすることはできないようです。これらの方法のいずれかを試してみると、例外が発生します。私が試したこと:
ANT スクリプトを使用して JavaFX アプリケーションをビルドします。以下は、ビルド スクリプトの関連部分のスニペットです。
<path id="classpath"> <fileset dir="${lib.dir}" includes="**/*.jar"/> <fileset dir="${javafx.sdk.path}/jre/lib" includes="jfxrt.jar"/> </path> <target name="compile" depends="clean"> <echo>Compiling the source</echo> <mkdir dir="${classes.dir}"/> <!-- Copy over the misc files into the classes dir --> <copy todir="${classes.dir}/bundles"> <fileset dir="${src.dir}/bundles"/> </copy> <copy todir="${classes.dir}/css"> <fileset dir="${src.dir}/css"/> </copy> <copy todir="${classes.dir}/img"> <fileset dir="${src.dir}/img"/> </copy> <copy todir="${classes.dir}/views"> <fileset dir="${src.dir}/views"/> </copy> <copy todir="${classes.dir}/bundles"> <fileset dir="${src.dir}/bundles"/> </copy> <copy file="${src.dir}/log4j2.xml" todir="${classes.dir}"/> <javac target="1.7" srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath" debug="on"> </javac> </target> <target name="jar" depends="compile"> <echo>Creating the main jar file</echo> <mkdir dir="${distro.dir}" /> <fx:jar destfile="${distro.dir}/main.jar" verbose="true"> <fx:platform javafx="2.1+" j2se="7.0"/> <fx:application mainClass="${main.class}"/> <!-- What to include into result jar file? Everything in the build tree--> <fileset dir="${classes.dir}"/> <!-- Define what auxilary resources are needed These files will go into the manifest file, where the classpath is defined --> <fx:resources> <fx:fileset dir="${distro.dir}" includes="main.jar"/> <fx:fileset dir="." includes="${lib.dir}/**" type="jar"/> <fx:fileset dir="." includes="."/> </fx:resources> <!-- Make some updates to the Manifest file --> <manifest> <attribute name="Implementation-Vendor" value="${app.vendor}"/> <attribute name="Implementation-Title" value="${app.name}"/> <attribute name="Class-Path" value="${lib.dir}"/> <attribute name="Implementation-Version" value="1.0"/> </manifest> </fx:jar> </target>
Ant スクリプトを使用して jar をコンパイル/生成すると、0.5 秒間ウィンドウ ポップアップが表示され、コンソールに "Exception in Application start method" がスタック トレースなしで表示されます。フラグを指定して Java を実行しようとしました-XX:-OmitStackTraceInFastThrow
が、それでもスタック トレースは表示されません。
実行する
javafxpackager
と、次のエラーが発生します。RenderJob.run: 内部例外 java.lang.UnsatisfiedLinkError: com.sun.prism.d3d.D3DContext.nSetBlendEnabled(JZ Z)I at com.sun.prism.d3d.D3DContext.nSetBlendEnabled(Native Method) at com.sun.prism .d3d.D3DContext.initState(D3DContext.java:84) com.sun.prism.d3d.D3DResourceFactory.(D3DResourceFactory.java:5 7) com.sun.prism.d3d.D3DPipeline.createResourceFactory(D3DPipeline.java: 147 ) com.sun.prism.d3d.D3DPipeline.getD3DResourceFactory(D3DPipeline.java: 153) で com.sun.prism.d3d.D3DPipeline.findDefaultResourceFactory(D3DPipeline.java:179) で com.sun.prism.d3d.D3DPipeline. com.sun.prism.GraphicsPipeline.getDefaultResourceFactory(GraphicsPipe line.java:97) の getDefaultResourceFactory(D3DPipeline.java:201) com.sun.javafx.tk.quantum.QuantumRenderer$3.com.sun. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) で、java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) で、prism.render.RenderJob.run(RenderJob.java:37) com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:98) で java.lang.Thread.run(Thread.java:724) でcom.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java :98) java.lang.Thread.run(Thread.java:724) でcom.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java :98) java.lang.Thread.run(Thread.java:724) で