Archive

Posts Tagged ‘deployment’

JavaFX – Deployment


I would like to highlight two import features in java deployment – Deployment Toolkit and Download-Service (available in Java 1.6.0_18). There is an excellent article on Deploying RIAs in Mixed Environments. This will help in understanding and resolving many of Java/JavaFX deployment issues. JavaFX deployment script – dtfx.js – already does lot of these checking. But these APIs will enable further customization related to JRE-Version, OS, Browser etc.



Please click on above image to load the HTML page with JavaScript which demonstrates use of these APIs

DownloadService provides APIs to query user cache. This can be used to request and update resources required by your application. It may be used to query existence of JavaFX runtime extension in cache. Sometimes this runtime is cached in “system” cache, and hence it may not be possible to query using this API. Please refer to DownloadServiceApplet.java and DownloadService.html for more information on usage. Entire list of JNLP Service APIs is available here. Refer to “Deployment” section in JavaFX Tutorials for more information..

Please try it out and let me know feedback..

Advertisements
Categories: javafx Tags: , ,

JavaFX – Passing Arguments

June 11, 2009 7 comments

I received a query on how to pass arguments in JavaFX. It basically depends on how we deploy the application. The application can be deployed using JavaWebStart, as an applet or launched from command line.

Lets take a simple application..


var text = Text {
    x: 10, y: 30
    font : Font size : 16 }
    content: "Argument {FX.getArgument( "key" )}"
}

The argument is passed as key-value pair. The value is retrieved using FX.getArgument( <key> ) method. Arguments can be passed to various deployment modes as shown below.

Command Line:


javafx -cp FXArguments.jar fxarguments.Main key="From Command Line"

Applet:


<script src="http://dl.javafx.com/1.2/dtfx.js&#34;></script>
<script>
    javafx(
        {
              archive: "FXArguments.jar",
              draggable: true,
              width: 250,
              height: 80,
              code: "fxarguments.Main",
              name: "FXArguments",
              key: "from Applet"
        }
    );
</script>

Launch Applet Example

Java Web Start:


<jnlp spec="1.0+" codebase="dist" href="FXArguments.jnlp">
    <application-desc main-class="com.sun.javafx.runtime.main.Main">
        <argument>MainJavaFXScript=fxarguments.Main</argument>
        <argument>key=from Java Web Start</argument>
    </application-desc>
</jnlp>

Launch Web Start Example

Source:

var dzone_url = “http://blogs.sun.com/rakeshmenonp/entry/javafx_passing_arguments&#8221;;
var dzone_style = ‘2’;

digg_skin = ‘compact’;
digg_window = ‘new’;

Categories: javafx Tags: ,

JavaFX – Where is Applet tag?!

April 15, 2009 8 comments

For deploying JavaFX in browser, we use JavaScript code as shown below


<script src="http://dl.javafx.com/1.1/dtfx.js&#34;></script>
<script>
    javafx(
        {
              archive: "JavaFX_Flickr_Image_Viewer.jar",
              draggable: true,
              width: 800,
              height: 650,
              code: "carousel.Main",
              name: "JavaFX_Flickr_Image_Viewer"
        }
    );
</script>

JavaFX uses dtfx.js which in turn uses deployJava.js to detect presence of java, the version of java on the system etc. Refer to Java Deployment Toolkit documentation for more information.

So how does JavaFX deploys as Applet without using Applet tag?

It indeed uses Applet tag, dtfx.js script generates the required Applet tag. It generates two <div> sections. The first section shows the spinning java logo and second sections embeds the Applet. First the spinning logo is shown, when applet is loaded, its visibility status is changed to false.

The generated html tags will be as shown below, which has embedded Applet tag



<script src="http://dl.javafx.com/1.1/dtfx.js&#34;></script>
<div id="deployJavaApplet1Overlay" 
    style="width:800;height:650;position:absolute;background:white">
    <table width=800 height=650 border=padding=margin=0>
    <tr><td align="center" valign="middle">
        <img src="http://dl.javafx.com/javafx-loading-100x100.gif"&nbsp;width=100 imgHeight=100>
    </td></tr>
    </table>
</div>
<div id="deployJavaApplet1" style="position:relative;left:-10000px">
    <APPLET MAYSCRIPT
        code="org.jdesktop.applet.util.JNLPAppletLauncher"
        archive="JavaFX_Flickr_Image_Viewer.jar,
        http://dl.javafx.com/applet-launcher__V1.1.1.jar,
        http://dl.javafx.com/javafx-rt__V1.1.1.jar,
        http://dl.javafx.com/fxdloader__V1.1.1.jar,
        http://dl.javafx.com/jmc__V1.1.1.jar,
        http://dl.javafx.com/Decora-SSE__V1.1.1.jar,
        http://dl.javafx.com/emptyJarFile-1239792034654__V1.1.1.jar&#34;
        width=800
        height=650>
        <param name="codebase_lookup" value="false">
        <param name="subapplet.classname" value="com.sun.javafx.runtime.adapter.Applet">
        <param name="progressbar" value="false">
        <param name="classloader_cache" value="false">
        <param name="draggable" value="true">
        <param name="MainJavaFXScript" value="carousel.Main">
        <param name="subapplet.displayname" value="JavaFX_Flickr_Image_Viewer">
        <param name="jnlpNumExtensions" value="2">
        <param name="jnlpExtension1" value="http://dl.javafx.com/jmc__V1.1.1.jnlp&#34;>
        <param name="jnlpExtension2" value="http://dl.javafx.com/Decora__V1.1.1.jnlp&#34;>
        <param name="jnlp_href" value="JavaFX_Flickr_Image_Viewer_browser.jnlp">
        <param name="deployJavaAppletID" value="deployJavaApplet1">
    </APPLET>
</div>

How will we get this generated Applet tag?

Just add displayhtml: true as shown below. This will display the html instead of loading the applet!


<script src="http://dl.javafx.com/1.1/dtfx.js&#34;></script>
<script>
    javafx(
        {
              archive: "JavaFX_Flickr_Image_Viewer.jar",
              draggable: true,
              width: 800,
              height: 650,
              code: "carousel.Main",
              name: "JavaFX_Flickr_Image_Viewer",
              displayhtml: true

        }
    );
</script>

var dzone_url = “http://blogs.sun.com/rakeshmenonp/entry/javafx_sudoku_css_support&#8221;;
var dzone_style = ‘2’;

digg_skin = ‘compact’;
digg_window = ‘new’;

Categories: javafx Tags: ,