分发/部署 JavaFX 应用程序

发布于 2024-08-15 20:57:16 字数 534 浏览 6 评论 0原文

我刚刚用 JavaFX 完成了一个小应用程序,并开始考虑如何分发它。 我认为这将是一个简单的问题,只需点击构建按钮并使用生成的文件之一即可。

由于某种原因构建创建:

  1. Jar 文件抱怨双击时无法找到其主类。
  2. jnlp 文件失败并显示“无法启动应用程序”。
  3. 一个 html 文件,当在浏览器中打开时,它会永远显示一个旋转的 java 徽标。

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

我想要一个可以下载/通过电子邮件发送、双击并运行的单个文件,无需大惊小怪。除此之外,一切都很容易。 :) 我非常确定您可以使用 Jar 文件来做到这一点,但是我使用 Netbeans 及其构建命令得到的结果非常荒谬。

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

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 file which complains it can't find its main class when doubleclicked.
  2. A jnlp file which fails saying "unable to launch application".
  3. An html file which, when opened in my browser shows a spinning java logo forever.

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?

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.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

执笏见 2024-08-22 20:57:17

过去,当使用 Netbeans 创建 JavaFX 时,我只使用了它创建的 jar 文件,而不使用 jnlp 或 html(如果没记错的话,它指向 localhost)。话虽如此,我手动创建了 .jnlp 以发布到我的服务器。
下面是我在 www.ericonjava.com 使用的 .jnlp 副本

 <?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" ...这应该是您的 url
  2. href="bubblebreaker/bubblebreaker.jnlp ...服务器上 .jnlp
  3. jar 的相对路径href="bubblebreaker/BubbleBreaker.jar"...服务器上 .jar 的相对路径
  4. application-desc main-class="bubblebreaker.Test" ...包名称和类名称

另外在 netbeans 中构建时...make确保右键单击项目选项卡并转到属性部分来设置 pack200 启用/可拖动小程序等属性,

我希望这会有所帮助。

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"/>

The important tag elements are the:

  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

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.

I hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文