JavaFX and JNLPs: How to Develop and Run JavaFX Applets and Applications Offline

By Thomas Ng

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 dtfx.js file:

    a. Replace the reference to with file:/c:/offline/deployJava.js.
    b. Replace the reference to with file:/c:/offline/javafx-loading-100x100.gif.
    c. Replace the reference to with file:/c:/offline/javafx-loading-25x25.gif.

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
    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=""/>
    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: <script src=""></script>
    b. Change it to the following: <script src="file:/c:/offline/dtfx.js"></script>

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 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.

Thomas Ng is a software engineer in the Java Deployment team at Sun Microsystems. He has worked on developing Java Web Start software since version 1.0.

Comments: results in a 404 error.

Posted by lqd on December 04, 2008 at 01:42 AM PST #

We apologize, there seems to be a server problem. It should be fixed sometime soon.

Posted by Christine Dorffi on December 04, 2008 at 02:41 AM PST #


Posted by pedro on December 06, 2008 at 07:50 PM PST #

I am getting a "Null Pointer" exception error.

Posted by Steven on December 14, 2008 at 08:52 PM PST #

Can you please provide the exact steps to reproduce the Null Pointer Exception please ?

Posted by Thomas Ng on December 15, 2008 at 02:28 AM PST #

SDK login session useful for accessing impartent files

Posted by santhi ramakrishnan on December 19, 2008 at 05:42 PM PST #

file with source code details required

Posted by santhi ramakrishnan on December 19, 2008 at 05:44 PM PST #

middlet applications and java process community with woking example required

Posted by santhi ramakrishnan on December 19, 2008 at 05:45 PM PST #

Santhi: Can you explain more on your comment please ? There is really no source code related to this tech tip. This is about how to develop and run your desktop FX applets/applications offline with NetBeans.

Posted by Thomas Ng on December 22, 2008 at 03:48 AM PST #

Very informative ! Thanks for the post.

Posted by Vaibhav on December 24, 2008 at 10:10 PM PST #

Thanks! very helpful

Posted by guest on January 09, 2009 at 08:56 PM PST #

All steps work wonderfully well with Netscape7.2 browser. However with Internet Explorer(even after enabling blocked content) and FireFox browsers the applet fails to load.
Any suggestions?

Posted by sudershan Mehta on January 19, 2009 at 02:44 PM PST #

All steps work wonderfully well with Netscape7.2 browser. However with Internet Explorer7(even after enabling blocked content) and FireFoxv3.0 browsers the applet fails to load.
Any suggestions?

Posted by sudershan Mehta on January 19, 2009 at 03:00 PM PST #

When i type
javaws -import
into my command line, i got the following exception in a new window Unable to load resource:
at Source)
at Source)
at Source)
at Source)
at Source)
at Source)
at com.sun.javaws.LaunchDownload.downloadJarFiles(Unknown Source)
at com.sun.javaws.LaunchDownload.downloadEagerorAll(Unknown Source)
at com.sun.javaws.Launcher.downloadResources(Unknown Source)
at com.sun.javaws.Launcher.prepareLaunchFile(Unknown Source)
at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
at com.sun.javaws.Launcher.launch(Unknown Source)
at com.sun.javaws.Main.launchApp(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main$ Source)
at Source)

Posted by Lenin on February 19, 2009 at 01:42 PM PST #

sudershan Mehta: Can you provide more information on the failure ? Do you get any error message or exception ?

Lenin: I just tried the import command again and it works. Maybe you run into an intermitten network problem ? Can you try again ?

Posted by Thomas Ng on February 26, 2009 at 08:04 AM PST #

Thanks Thomas. The import statement worked now and i can run my application OFFLINE.
When will the JRE comes pre-installed with JavaFX Runtime?

Posted by Lenin on May 05, 2009 at 03:53 AM PDT #

Rather than doing all these work arounds, does anyone know if there will be any support in packaging all these necessary files either within netbeans or jdk's? The bigger issue I see is that if you are doing development in a closed network which I'm sure a lot of companies are, deployment of javafx based browser applications present problems. Seems like any development with JavaFX assumes you will have access to the NET so that it can download the necessary tag files and libraries. We could do all these as a work around, but when a new version of javafx is release, does that me we have to redo everything and re-test everything to make sure we get the new versions in place and working? Dont make too much sense to me.

Posted by Rich on June 18, 2009 at 09:21 AM PDT #

... and how is that install made in a pure "without-internet" environment ? If we can't connect - not one time - to the net, the application won't start anymore ? I agree with Rich, without a correct packaged solution I can't take the risk to invest on hours configuring/installing/testing ... On a hot project, I would say that Flex will do the work instead.

Posted by galyathee on September 13, 2009 at 04:46 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed

Tips for developers who use Java technologies (Java SE, Java ME, JavaFX) for mobile and embedded devices.


« July 2016