Distributing/deploying JavaFX apps
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.
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:
- codebase="http://www.ericonjava.com" ...This should be your url
- href="bubblebreaker/bubblebreaker.jnlp ...the relative path on your server to the .jnlp
- jar href="bubblebreaker/BubbleBreaker.jar"...relative path on your server to the .jar
- 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.
精彩评论