JavaFX and JNLPs: How to Develop and Run JavaFX Applets and Applications Offline
By Christine Dorffi on Dec 03, 2008
While developing your JavaFX applet or application by using NetBeans IDE 6.5 for the JavaFX 1.0 platform, you might want to run the JavaFX application/applet offline for debugging and testing purposes. Following are the steps to run the JavaFX application or applet when your machine is disconnected from the network.
You must have Java SE Development Kit (JDK) 6 Update 10 (or later) installed on your local machine.
Your applet or application must be JNLP enabled.
1. Download the following files to your local machine:
2. Save the files to a local directory on your machine. For example:
3. Edit the
- a. Replace the reference to
b. Replace the reference to
c. Replace the reference to
4. While your machine is connected to the network, run the following command, which ensures that the latest JavaFX runtime is installed into your local cache:
javaws -import http://dl.javafx.com/javafx-cache.jnlp
This command ensures the latest JavaFX runtime is cached in your system. You will see a Java splash screen, followed by a progress dialog box, if any download takes place. After that, the command will exit silently, which means you now have the latest JavaFX runtime cached. If an error is encountered, an error dialog box appears.
5. Disconnect your machine from the network.
6. Ensure that the JNLP file for your JavaFX applet or application uses the following
<extension> tag for its JavaFX runtime:
<extension name="JavaFX Runtime" href="http://dl.javafx.com/javafx-rt.jnlp"/>
This is the default that is generated by the NetBeans IDE. This allows your application/applet to be launched offline by using the cached JavaFX runtime.
7. In your applet or application HTML page, change the reference of
dtfx.js to your local copy.
- a. For example, find this reference:
b. Change it to the following:
8. Run your application or applet offline.
The compile and run functions of the NetBeans IDE always regenerate the HTML and JNLP files of your JavaFX applet or application and overwrite the changes you made to default value of
http://dl.javafx.com instead of to your local copy. Therefore, you must make a copy of these offline-specific HTML and JNLP files and navigate to them directly when running offline. Remember to change the JNLP href in each offline JNLP file that points to the offline copy.
You can continue to work on your JavaFX applets and applications while your computer is offline.