Javafx 2 JavaFX2.0应用程序引用外部JAR
我正在使用Netbeans 7开发一个JavaFX2.0应用程序。 主应用程序引用通过右键单击“库”文件夹并选择“添加项目…”添加的另一个类库项目。从netbeans执行应用程序工作正常 当通过“Clean and build”将其部署到jar文件中并尝试通过控制台使用Javafx 2 JavaFX2.0应用程序引用外部JAR,javafx-2,Javafx 2,我正在使用Netbeans 7开发一个JavaFX2.0应用程序。 主应用程序引用通过右键单击“库”文件夹并选择“添加项目…”添加的另一个类库项目。从netbeans执行应用程序工作正常 当通过“Clean and build”将其部署到jar文件中并尝试通过控制台使用 java -jar TestApp.jar 我明白了 我的应用程序的dist/lib文件夹包含引用的库。所以我想一切都会好起来的。查看我的应用程序jar中包含的Manifest.MF,我发现 Manifest-Version:
java -jar TestApp.jar
我明白了
我的应用程序的dist/lib文件夹包含引用的库。所以我想一切都会好起来的。查看我的应用程序jar中包含的Manifest.MF,我发现
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.2
Created-By: 1.6.0_23-b05 (Sun Microsystems Inc.)
Implementation-Vendor: pmoule
Implementation-Title: TestApp
Implementation-Version: 1.0
Main-Class: com/javafx/main/Main
JavaFX-Application-Class: testapp.TestApp
JavaFX-Version: 2.0
我的班级路径在哪里?如何让Netbeans添加正确的类路径
我试图通过编辑jar中包含的Manifest.MF手动将其添加到Manifest.MF中
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.2
Created-By: 1.6.0_23-b05 (Sun Microsystems Inc.)
Implementation-Vendor: pmoule
Implementation-Title: TestApp
Implementation-Version: 1.0
Class-Path: lib/MyLib.jar //THIS IS NEW
Main-Class: com/javafx/main/Main
JavaFX-Application-Class: testapp.TestApp
JavaFX-Version: 2.0
没有成功,同样的错误
JavaFX 2.0 SDK附带的所有示例都可以通过双击WindowsExplorer或从控制台输入
java -jar PathAnimation.jar
但这些示例中没有一个引用外部jar
一些研究让我想到了这个问题:
但到目前为止还没有任何解决办法
谢谢你的帮助 在Netbeans中,在project=>properties=>Build=>Packaging下,您是否检查了“复制相关库”我自己找到了一个有效的解决方案 dist/lin文件夹中的所有外部库的大小均为0kb。当然,例外情况是正确的 为了让我的应用程序运行,我在项目的jfx-impl.xml中执行了以下操作: 将类路径添加到manifest.mf
<fxjar destfile="${jfx.deployment.dir}/${jfx.deployment.jar}" applicationClass="${main.class}" >
<fileset dir="${build.classes.dir}"/>
<manifest>
<attribute name="Implementation-Vendor" value="${application.vendor}"/>
<attribute name="Implementation-Title" value="${application.title}"/>
<!-- NEW --> <attribute name="Class-Path" value="${jar.classpath}"/> <!-- NEW -->
<attribute name="Implementation-Version" value="1.0"/>
</manifest>
</fxjar>
我新创建的web目录的内容仍然存在一些问题
希望这对其他人有所帮助。您需要告诉fx:jar任务您的类路径依赖关系是什么:
<fxjar destfile="${jfx.deployment.dir}/${jfx.deployment.jar}" applicationClass="${main.class}" >
<fileset dir="${build.classes.dir}"/>
<manifest>
<attribute name="Implementation-Vendor" value="${application.vendor}"/>
<attribute name="Implementation-Title" value="${application.title}"/>
<attribute name="Implementation-Version" value="1.0"/>
</manifest>
<!-- Setup the classpath for the generated .jar here -->
<fx:resources>
<fx:fileset type="jar" dir="lib" includes="MyLib.jar"/>
</fx:resources>
</fxjar>
您还需要在fx:deploy任务中使用fx:resources标记,而不仅仅是资源。这将解决您答案中剩下的最后两个问题。感谢您的提示,该选项已选中。正如我所写的,项目的dist/lib文件夹在执行“清理并构建”后包含有问题的库。您是否按照以下说明进行FXDeployment?是的,我遵循了部署指南中的说明。我甚至更新了JavaFX的Netbeans插件,并更新了项目的构建文件。没有任何外部jar的部署工作正常。当包含一些外部jar时,问题就出现了。更新:为了满足上面列出的要求,我将平台更改为JDK 6_26;我将这一行添加到项目的jfx-impl.xml
中的fxjar任务中。现在,类路径包含在manifest.mf中。错误仍然是相同的:(
<property name="jfx.deployment.web.dir" location="${jfx.deployment.dir}/web" />
<mkdir dir="${jfx.deployment.web.dir}" />
<fxdeploy width="${jfx.applet.width}" height="${jfx.applet.height}"
outdir="${jfx.deployment.web.dir}" <!-- NEW DIR -->
embedJNLP="true"
outfile="${application.title}">
<info title="${application.title}"
vendor="${application.vendor}"/>
<application name="${application.title}"
appclass="${main.class}"/>
<resources type="eager">
<fileset dir="${jfx.deployment.web.dir}"> <!-- NEW DIR -->
<include name="${jfx.deployment.jar}"/>
<include name="lib/*.jar"/>
<exclude name="**/jfxrt.jar"/>
</fileset>
</resources>
</fxdeploy>
java -jar TestApp.jar
<fxjar destfile="${jfx.deployment.dir}/${jfx.deployment.jar}" applicationClass="${main.class}" >
<fileset dir="${build.classes.dir}"/>
<manifest>
<attribute name="Implementation-Vendor" value="${application.vendor}"/>
<attribute name="Implementation-Title" value="${application.title}"/>
<attribute name="Implementation-Version" value="1.0"/>
</manifest>
<!-- Setup the classpath for the generated .jar here -->
<fx:resources>
<fx:fileset type="jar" dir="lib" includes="MyLib.jar"/>
</fx:resources>
</fxjar>