分发/部署JavaFX应用程序 [英] Distributing/deploying JavaFX apps

查看:166
本文介绍了分发/部署JavaFX应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在JavaFX中完成了一个小应用程序,并开始思考如何分发它。
我认为这是一个简单的问题,即按下构建按钮并使用其中一个结果文件。

I am just finishing up a little app in JavaFX and am starting to think about how to distribute it. I figured this would be a simple matter of hitting the build button and using one of the resulting files.

由于某种原因,构建会创建:

For some reason build creates:



  1. Jar文件抱怨它在双击时找不到它的主类。

  2. 一个无法说无法启动应用程序的jnlp文件。

  3. 一个html文件,当我在浏览器中打开时,会永远显示一个旋转的java徽标。


所有这些让我相信我的Java设置有问题。我怎样才能将这个项目打包出门?

All of this leads me to believe that there is something wrong with my Java setup. How can I get this project packaged up and out the door?

我希望有一个文件可以下载/通过电子邮件发送,双击并轻松运行。没错,不管多么容易。 :)我很确定你可以用Jar文件做到这一点,但我用Netbeans及其构建命令得到的结果非常荒谬。

I would like to have a single file that can be downloaded/emailed, doubleclicked and run without a fuss. Short of that, whatever's easy. :) I am pretty sure you can do that with a Jar file but what I am getting with Netbeans and its build command is pretty ridiculous.

重要细节:我正在运行Ubuntu Karmic。我已经切换到Sun Java而不是OpenJDK(它似乎非常糟糕地处理JavaFX)但我认为firefox仍在使用OpenJDK。

Important details: I am running Ubuntu Karmic. I have switched over to Sun Java instead of OpenJDK (which seems to deal with JavaFX very badly) but I think firefox is still using OpenJDK.

推荐答案

过去,当使用Netbeans创建JavaFX时,我只使用了它创建的jar文件而不是jnlp和html(如果内存正确地为我提供了它指向localhost)。话虽如此,我手工创建.jnlp以便发布到我的服务器。
以下是我在 www.ericonjava.com 上使用的.jnlp副本

In the past, when using Netbeans to create JavaFX I have only used the jar files it has created and not the jnlp nor the html (if memory serves me correctly it points to localhost). With that said, I hand create the .jnlp for publication to my server. Below is a copy of a .jnlp I use at www.ericonjava.com

 <?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="http://www.ericonjava.com/" href="bubblebreaker/bubblebreaker.jnlp">
<information>
    <title>Bubble Breaker</title>
    <vendor>www.ericonjava.com</vendor>
    <homepage href="http://www.ericonjava.com"/>
    <description>Bubble Breaker</description>
    <offline-allowed/>
</information>
    <j2se href="http://java.sun.com/products/autodl/j2se" version="1.6+"/>
<property name="jnlp.packEnabled" value="true"/>
    <extension name="JavaFX Runtime" href="http://dl.javafx.com/1.1/javafx-rt.jnlp"/>
      <jar href="bubblebreaker/BubbleBreaker.jar" main="true"/>
</resources>
<application-desc main-class="bubblebreaker.Test"/>

重要的标签元素是:


  1. codebase =http://www.ericonjava.com......这应该是你的网址

  2. href =bubblebreaker / bubblebreaker.jnlp ...服务器上相对路径为.jnlp

  3. jar href =bubblebreaker / BubbleBreaker.jar...服务器上的相对路径为.jar

  4. application-desc main-class =bubblebreaker.Test...包名称和类名

  1. codebase="http://www.ericonjava.com" ...This should be your url
  2. href="bubblebreaker/bubblebreaker.jnlp ...the relative path on your server to the .jnlp
  3. jar href="bubblebreaker/BubbleBreaker.jar"...relative path on your server to the .jar
  4. application-desc main-class="bubblebreaker.Test" ...package name and class name

同样在netbeans中构建时...确保右键单击项目选项卡并转到属性部分以设置类似pack200 enabled / Draggable Applet的属性。

Also when building in netbeans...make sure you right click the project tab and go to the properties section to set properties like pack200 enabled/Draggable Applet.

我希望这会有所帮助。

这篇关于分发/部署JavaFX应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆