Java Download Service Listener


Bookmark and Share

One of the previous post [Applet Startup Time] provided a way to measure start-up time of JavaFX Applets. Many responded with requested information (Thanks a lot!). One of the main concern raised was high start-up time for “Without JavaFX Runtime”. This is high because it includes time taken to download and install JavaFX Runtime.

Unfortunately there was no way to notify the user about exact progress of this. Hence user will not be able to differentiate between download and install of “JavaFX Runtime” and “JavaFX Application”.

Recent JavaFX Update 1.2.3 reduced the download size and start-up time. You can notice this change by trying out the start-up time measurement applet again.. But still it doesn’t provide a way to exactly notify the start-up progress. We can only specify a custom splash-screen as specified here.

And then we have Java Update 1.6.0_18 Not sure how many of you noticed this feature – Download Service Listener It allows you to provide a Custom Progress UI using AWT/Swing/Java2D APIs. It has callback methods which will provide information related to download and validation of resources. Please refer to Download Service Listener Example for more information. Refer to ProgressListener.java and ProgressView.java for implementation used in this sample.


To launch click on above image or

Now we can implement custom progress listener with actual values. We can use the same approach for JavaFX applications as well. There is minor issue in using this feature with JavaFX Applet deployed using dtfx.js. This script is not updated to utilize this feature. So for now we need to explicitly hide the default splash screen by invoking JavaScript method hideOverlay as shown in ProgressListenerFX.html

Reference:

Hmm.. thatz a long post with lots of information.. But I think its very useful.. As usual, please try it out and let me know feedback..

Advertisements

About Rakesh Menon
-

8 Responses to Java Download Service Listener

  1. Carl Dea says:

    Rakesh,

    Java Plug-in 1.6.0_18
    Using JRE version 1.6.0_18-b07 Java HotSpot(TM) Client VM
    MS Windows XP Professional version 2002 SP Pack 3
    Pentium(R)4 HT 3.4 GHz

    First time launch:
    4.264 seconds

    Second time launch Reload:
    .371 seconds

    Third time launch Reload:
    .378 seconds
    I forgot to copy previous console outputs but here it is for the third load:
    HTML_TIME : 1265822927001
    APPLET_TIME: 1265822931265
    LOAD_TIME : 4264.0 Milli-Seconds
    HTML_TIME : 1265822958347
    APPLET_TIME: 1265822958718
    LOAD_TIME : 371.0 Milli-Seconds
    HTML_TIME : 1265822976434
    APPLET_TIME: 1265822976812
    LOAD_TIME : 378.0 Milli-Seconds

    Fourth time: Wow!

    HTML_TIME : 1265822927001
    APPLET_TIME: 1265822931265
    LOAD_TIME : 4264.0 Milli-Seconds
    HTML_TIME : 1265822958347
    APPLET_TIME: 1265822958718
    LOAD_TIME : 371.0 Milli-Seconds
    HTML_TIME : 1265822976434
    APPLET_TIME: 1265822976812
    LOAD_TIME : 378.0 Milli-Seconds
    HTML_TIME : 1265824105242
    APPLET_TIME: 1265824105484
    LOAD_TIME : 242.0 Milli-Seconds

    Next, I plan to do it on a Vista machine

    I have had other application running of coarse while running the applet, so the times I’m sure should be better.

    Yep, pretty impressive! You guys are heroes… Applets making a comeback (finally).

    How do you clear the cache again?

    -Carl

    • Rakesh Menon says:

      @Carl Great! May be I must collect these new data and compare with the previous startup data.. 🙂
      Latest JRE installers downloads and saves JavaFX Runtime in “system” cache.. You can remove
      both user and system cache entry using below commands..

      javaws -system -uninstall
      javaws -uninstall

  2. Pingback: JavaFX – Applet Startup Time « Rakesh Menon

  3. Pingback: JavaFX – Performance Optimization « Java, JavaFX and beyond…

  4. Antoine says:

    Hi Rakesh,

    Nice post.
    Do you think it’s possible to create a JavaFX stage instead of a Swing panel? I made a quick try running com.sun.javafx.runtime.main.Main in the constructor of my progress listener implementation, but it does not work. The javaws process just “vanish” with no message and no crash log…any idea if this should be possible to get this working?

    • Rakesh Menon says:

      I don’t think its supported.. The interface is suitable for AWT/Swing implementation.. Also I think it will be better to have a very lightweight splash-screen (Downloading (if required) and start-up of JavaFX runtime adds to start-up time). Are you using any specific feature in JavaFX for splash-screen?

      • Antoine says:

        No, no specific reason for using JavaFX – I was just curious and a bit lazy going back to Swing 😉
        Thanks for your answer!

  5. Daniel Ziltener says:

    Hmm, seems like it’s not functional on linux – I’m using Mandriva 2010.1 with the Sun Java 6 Update 20 Plugin.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: