Ryan has posted 17 posts at DZone. You can read more from them at their website. View Full User Profile

Trying Out Java 6u10 Applets

  • submit to reddit

The other night I downloaded Java 6 Update 10 (JDK) and installed it on my Windows Vista laptop to test drive the new applets plugin. I found that some applets show off the speedy startup time better than others. For example, I would say that every one of the applets at Applet Depot loads and is usable nearly instantaneously. Interestingly, the DotToDot applet crashed Firefox 3 many times, but works now?

On the other hand, every one of Report Mill's JavaFX Gallery applets take a good 10-30 seconds or longer to load. I have to watch the orange Java logo and progress bar while they load. Even after they load, some of them show a blank screen for 10+ seconds. What's different? 814KB of .jar dependencies. I wonder if the javafxrt.jar etc. are obsolete now with compiled JavaFX Script? That would cut out a lot of download time.

The progress bar in the orange Java logo indicates how much of the applet and dependencies have been downloaded so far. I know you can replace the orange Java logo with a custom animated GIF, but I don't know how you would make it interact with the applet plugin to be able to draw a progress bar like that.

fig-1.png15.14 KB
Published at DZone with permission of its author, Ryan Developer. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)



Osvaldo Doederlein replied on Wed, 2008/10/22 - 1:55pm

I checked the interactivepulp applets... pretty cool. Demos like that show that Java 6u10 is easily competitive with Flash; there's really NO loading-time or usability delta from Flash to Java. And on top of that, I doubt even Flash 10 (with their latest tracing JIT) can match the performance of HotSpot for the most compute-intensive demos. See their version of BubbleMark for example, it scores insane FPS numbers - I can get sustained ~75fps with 512 balls, and ~3200fps with 1 ball. (Plus, no human-observable GC pauses in either test.) And I should add that the demo code is very simple, for one thing it does a cartesian-product in the collision logic, so 512 balls need 133 million invocations of Ball.doCollide() (implemented with double-precision FP)... this alone would probably bring a straight Flash port's performance to the ground. Now, of course this code could be optimized, e.g. simple 2D space partitioning would greatly reduce the number of collision checks, and I could manually "vectorize" the remaining checks, and remove what seems to be unnecessary synchronization, or make it multithreaded because even under stress it only uses ~27% of my quad-core CPU. But then, we could have a more sophisticated app with similar amount of computation even after optimization - and then, Flash is dead.

P.S.: Their 2D animation framework uses a nice optimization called "Dity Rectangles". It's simply a list of the rectangular regions used by each sprite, so at each frame the system only needs to redraw a clipping area composed by the union of all such recangles (before and after the last updates in all sprites' positions) . This is very effective to minimize video memory blitting when moving objects are a small fraction of the total scene area (like in a 1-ball test, or even a few balls). You only need well-tuned code to build, maintain, and scan the dirty-rects structure very efficiently. This brings be fond memories of Michael Abrash's computer graphics column in Dr. Dobb's Journal, that should be ~15 years ago... all C and Assembly code of course (we used to be Real Programmers, back then). Sh*t, I'm a old hacker.

Osvaldo Doederlein replied on Wed, 2008/10/22 - 2:29pm

Complementing my last post... so I went to the bubblemark site and tested the Flash 9 version (with Flash 10 installed). The max balls option was 128, with a performance of ~110fps ("cacheAsBitmap" version, which is by far the fastest). At 128 balls, the Java PulpCore version sustains ~210fps (in all my tests, I disable CAP Frame Rate and enable the other two options). That makes Java 2X faster, even in a test that's still more API/runtime/videocard-intensive than CPU-intensive (requires only 16k collision checks per frame). Flash is stuck at exactly 200fps with 1 ball, but that should be a max FPS cap. JavaFX (Image rendering) does 100fps at 100 balls but it's capped too. (Earth to JavaFX advocates: fix your version so the last option is 128 balls and not 100, and to have an option to disable the FPS capping.)

Ivan Lazarte replied on Wed, 2008/10/22 - 4:35pm

Apparently Chrome support has been added to the InteractivePulp nightly.  This is an exciting little lib that I'd like to investigate.  Sigh... Just wish it were easier to jump into this stuff for a server-side programmer.  It's a different universe.

Ron Wertz replied on Fri, 2008/10/24 - 11:59am

Is anyone else having problems with the demo applets or javaFX gallery on Vista home premium?  I normally develop on XP and have no problems with applets.  We're setting up a new laptop which is running Vista & IE 7; I've loaded all windows changes, reloaded JAVA, turned off protected mode, disabled UAC...

 I've never worked with Vista but it doesn't seem to run any applets from any site.  However on http://java.com/en/download/index.jsp it reports java is successfully loaded and the java icon displays in the bottom right?  I've reviewed security but maybe I'm missing something.

 Hope it's ok to ask here.

Otengi Miloskov replied on Sun, 2008/10/26 - 7:05am

I'm agree the Applets speed is very impressive much better than Flash or Silverlight. JavaFX is just sugar over Java so for designers can create more easy GUI but for Java programmers, Java is the way to go. I just hope they release SceneGraph API soon for Java developers.

Jose Smith replied on Sun, 2008/10/26 - 10:27am

I was a bit disappointed when I first tried 6u10 yesterday.

First, I uninstalled Java 6u7 SDK completely from my computer.  Then I searched the internet for a Java applet that uses the kernel installer/deployment toolkit so I could see for myself how long it takes for a user without java to see a basic applet.  I assumed there would be plenty of examples of this, but I couldn't find one.

So I decided to use the kernel installer directly from from java.sun.com, then quickly navigate to the Applet Depot linked above to see how transparent the process would be.  The kernel installer went really fast.  The last dialog said "JavaFX will be installed when you click close".  I clicked close and then immediately navigated to the clock example on applet depot.  The applet didn't appear at all, so I closed and restarted the browser.  The clock example needed to download additional Java classes (although it wasn't immediately apparent since my browser was on my second monitor and the Java download dialog appeared on the primary monitor).  After the download dialog closed the clock was present, but it wasn't functional (the hands weren't moving - it looked like a static gif).

At this point I wanted to be able to check what percentage of the JRE was downloaded - maybe that's why the clock wasn't working?  Is JavaFX fully installed?  I don't know!  I didn't really know what state the kernel instaler was in and I couldn't find any thing in the control panel or system tray to tell me this.  As a developer, I don't like thing's being "half-installed", so I uninstalled the JRE and downloaded the entire SDK manually.

Finally, the clock applet worked fine.  However, many of the Applet Depot applets managed to crash Firefox 3 - something I've never seen before on this new computer I built several months ago.  I thought 6u10 was supposed to prevent this by separating Java from the browser.

Moving on to web start apps....

I tried the Swirling Squares java web start app on JavaFx.com.  That's pretty slick - transparent, non rectangluar spinning rectangles on my desktop! :)  I still have three complaints with Java Web start apps.

 1) "Always trust content from this site" is by default checked.  This is fine for sun.com, but when I venture out into the interwebs, I don't want to accidentally trust content from some random site.

 2) Speaking of this, why do I need to check that box just to see a bunch of swirling squares.  I thought that was only necessary if the Java Web start app required access to my local file system.

 3) Do I really need an entry in Window's Add/Remove programs for "Swirly Squares" ??  Seriously.  Imagine if every Flash website you visited added an entry in there.  On my older vista box, I have approximately 15 dead java web start entries in there that i cannot remove due to various errors when I click "Uninstall".  I'm smart enough to know I can remove them via the Java control panel - a nomal user may not be.  That still leaves all these dang entries in Add/Remove programs though. The only way to remove them (that I know) is to edit the registry.  I'm of the opinion that Java web start applications do not belong in the Add/Remove programs section (probably because 99.9% of all the java web start applications I've ever used are Demo applications).

Florin Gheorghies replied on Sun, 2008/10/26 - 10:57am

Where can I find how applets interract with elements on the page? Is it both ways? Can indeed JavaScript talk to the applet?



Ryan Developer replied on Sun, 2008/10/26 - 11:03am

You brought up some good points, especially about the usability of a partially installed JRE.  I only installed the JDK and haven't looked at plain JRE yet. 

Is anyone from Sun following these comments?  How can we make sure Sun sees all of this feedback? 

Florin Gheorghies replied on Sun, 2008/10/26 - 1:24pm in response to: Jose Smith


You touch two points that make my jaw drop. Indeed I mentioned these in other posts yet there is no way to know that Sun is considering them.

1. Why is there a need to 'trust' an applet that does not access resources outside the sandbox?

2. Why they require Add/Remove for jnlp files? 

The reasoning behind these decisions blow my mind. It seems that some people that have no understanding of usability are making decisions for Java. I don't know how to express my bewilderment while remaining civil and respectful.

Good luck Sun. Success is never too late for any party. Will you make this a success this time around?

Osvaldo Doederlein replied on Mon, 2008/10/27 - 6:40am

In the Add/Remove dept, I guess the answer is that JAWS is supposed to compete with conventional desktop applications, and not with Flash. So it follows the same principles including allowing uninstallation from the standard Windows control applet. It's Java Applets that are most comparable with Flash (both run inside a web page) so they don't get registered in Add/Remove. I think all these JAWS demos out there are bad examples, JAWS is not well suited for this task - simple demos of JavaFX, scenegraph and other cool APIs - it's suited for productivity or business applications, with significant size and real need of running outside the browser.

I suppose that when a JAWS app is installed, its resources and jars are "locked" in the JRE cache, i.e. they won't be evicted out of the disk due to some space or inactivity limit. This makes the Add/Remove entry absolutely necessary because it's the only way (other than the Java Control Panel) to recover that disk space. OTOH, Java Applets are stored in the JRE cache, but (again just guessing) that's a LRU cache from which older, less accessed files can be removed after some time - so, no need of an explicit Remove option. Any JAWS expert can comment on these suppositions? The JNLP specification (updated for 6u10) doesn't require that JAWS app's files are cached permanently, it only says that "Resources belonging to a particular application are never removed from the cache while the application is running" which is pretty obvious and also valid for Applets... but implementations can have stronger behaviors than required by specifications. The spec doesn't enter in platform-specific details like the interaction with Windows' Add/Remove applet, and also launching shorcuts - JAWS apps can create shortcuts in the desktop and Start Menu, so the Add/Remove entry is important to clean these up; Applets have no shortcuts, so once again, they don't need any explicit uninstallation option.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.