分发/部署 JavaFX 应用程序
我刚刚用 JavaFX 完成了一个小应用程序,并开始考虑如何分发它。 我认为这将是一个简单的问题,只需点击构建按钮并使用生成的文件之一即可。
由于某种原因构建创建:
- Jar 文件抱怨双击时无法找到其主类。
- jnlp 文件失败并显示“无法启动应用程序”。
- 一个 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:
- Jar file which complains it can't find its main class when doubleclicked.
- A jnlp file which fails saying "unable to launch application".
- 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
过去,当使用 Netbeans 创建 JavaFX 时,我只使用了它创建的 jar 文件,而不使用 jnlp 或 html(如果没记错的话,它指向 localhost)。话虽如此,我手动创建了 .jnlp 以发布到我的服务器。
下面是我在 www.ericonjava.com 使用的 .jnlp 副本
重要的标签元素是:
另外在 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
The important tag elements are the:
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.