How-To's > How do I deploy my application?
You can deploy your JavaFX application as follows:
- A stand-alone desktop application
- A Java Web Start application
- An applet run in a browser
- A mobile application
You can easily package and deploy any of these types of applications in the NetBeans IDE, which automatically generates the appropriate files for the type of application you choose. As an alternative, you can use the JavaFX Packager tool and other commands included with the JavaFX SDK, as described in the following sections. See the links at the end of this topic for more detailed information about how to package and deploy JavaFX applications.
Stand-Alone Desktop Application
Compile your desktop application by using the javafxc command. Run the application by using the javafx command.
Java Web Start Application
To deploy your application as a Java Web Start application, package all classes and resources for your application in one or more JAR files. Then create a JNLP file for your application. Install the JAR and JNLP files on a server. Then add a link to your HTML page to launch your Java Web Start application.
If you build the application in the NetBeans IDE, you need only to edit the JNLP file so that the codebase element contains a correct URL that points to the location of this JNLP file. Outside of the NetBeans IDE, use the JavaFX Packager tool.
Applet
To deploy your applet, create application_name.jar and application_name_browser.jnlp files and install them on a server. If you use the NetBeans IDE to generate the appropriate files, edit the codebase and homepage variables in application_name_browser.jnlp file to point to the correct location of the application files and to the HTML page where the applet appears.
Embed the applet in your HTML page by inserting the following markup in the position at which the applet appears:
<script src="http://dl.javafx.com/1.2/dtfx.js"></script>
<script>
javafx(
{
archive: "Rollover.jar",
draggable: true,
width: 280,
height: 100,
code: "rollover.Main",
name: "Rollover"
}
);
</script>
Notes:
- Ensure that the first
scripttag contains the URL for dl.java.com with the correct version number. - The
draggablevariable refers to whether the viewer can drag the applet from the browser to the desktop. This feature is available with Java SE Version 6 Update 10 release at minimum, installed on the viewer's system. - The
widthandheightvariables should match the size of your stage, in pixels. - The
codevariable contains the entry point to your code. In the example, the package name isrolloverand the entry point isMain.fx. - The
namevariable contains the name of the application, and it should match the name of the main JAR file.
Mobile Application
Ensure that you use the JavaFX API common profile when you develop your application. Otherwise, your application will not run on the mobile platform. To test your application, you can use the JavaFX Mobile Emulator embedded in the NetBeans IDE, which is currently available on the Windows platform. You can download the NetBeans IDE from the javafx.com web site.
Links to Articles About Deployment
- Deploy A Rich Internet Application Developed With JavaFX Technology
- JavaFX Applets in the Browser
- Make JavaFX Browser Applets Draggable
- Java Web Start
- Deployment In-Depth
Examples of JNLP files
- FXMediaViewport.jnlp
An example of a JNLP file for a Java Web Start application. - FXImageViewport_browser.jnlp
An example of a JNLP file for an applet.
Last Updated: November 2009
[Return to How-To's Home]
Do you have comments about this article? We welcome your participation in our community. Please keep your comments civil and on point. You may optionally provide your email address to be notified of repliesyour information is not used for any other purpose. By submitting a comment, you agree to these Terms of Use.