How to make the javaFX applet running offline

By W.ZH Aug 30 2010Issue:

When I build a JavaFX UI by netbean, and it can be deployed as a single java application, or can be deployed as a applet page to run in web application. But if it runs as an applet, it must go to javafx.com website to download many jars and other files to run the applet. So your web application must keep access to the internet to run it. So this article is going to help you can make it run in the enterprise intranet environment.



Analysis:  We have understand how a applet is trigger to open for javafx in web application. After you deploy from netbean, you get an html like this, myApp.html together with a myApp.jnlp file:

<html>

<head>

<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″>

</head>

<body>

http://dl.javafx.com/1.3/dtfx.js

javafx(

{

archive: “myApp.jar”,

draggable: true,

width: 300,

height: 400,

code: “myApp.Main”,

name: “myApp”,

displayhtml: false

}

);

</body>

</html>

dtfx.js in fact is a set of javascript to check your client browser and dynimic create the applet html tag for you, based on the javaFX runtime versions and also your myAPP.jnlp file.

Solution:

You can read this article
http://blogs.sun.com/mobility_techtips/entry/how_to_develop_and_run . it basiclly explain how you an do to make it offline. But i list several tips here:

1. The js, and pic resources URL might different upon your FX version.  And even the files are different. My experience is you need dtfx.js, deployJava.js, and ping .js (maybe).  and those pics.

2. You need read the dtfx.js, deployJava.js, javafx-rt.jnlp code to find out what jars it needs, it will different with the article mentioned. I download aorund 20+ jars for 1.3 version javafx runtime, as they are for different os and browser.

3. then change all java script and also the jnlp files link to internet resource to let them point to your offline files and jars, and also your app’s html and jnlp files.  Then you should be able to run it offline.

4. Understand how dtfx.js works is very important. you can change it upon your needs, As i need to change a lot in the applet input parameters, So change myApp.html and also the dtfx,js can help a lot on this issue.

5. You can change  myApp.html to a jsp page, so it can merge into your J2EE web application, you can create dynamic input for the applet in jsp and make your javaFX runs in your J2EE context.

6. Shortcoming for offline version is that when the new version javaFX runtime release, you can not get update…but this is how current javaFX works,, I feel javaFX is still in early stage to be stable to use.

 

 

Advertisements