Slow startup JRE on CD/USB

Recently I had to make an offline CD containing my Java Web Start application. Since it had to be as idiot-proof as possible I put the extracted JRE on the CD and a simple Visual Basic frontend program that launched the application’s jar file with the java.exe from the CD.

This worked, however starting the program for the first time takes about 30 seconds. Subsequent launches take around 2 or 3. I’ve tested the CD’s content from a local harddisk, a network drive and a USB stick as well. On the local disk and the network drive the first launch takes about 6 seconds, so it’s not my program or Java itself being slow. The USB stick took around 20-30 seconds.

My guess was that it’s limited by the read speed of the CD/USB, but the JRE is only about 50 MB, so both should be able to read it in around 10 seconds tops.

It’s not a problem with a virus scanner since the issue was replicated on a computer without one installed.

Anyone have any ideas what causes the initial delay or an alternative equally idiot-proof way to distribute Java programs on a CD?

The jars of the JRE are uncompressed. Usually its faster this way. However, with slower seeks it should be better if they are compressed. So, zip em (max).

You can also take that one step further by checking in which order the classes are loaded by your application (-verbose:class) and change their order accordingly. This should eleminate lots of seeking. Never tried it myself, but thats something which is often done for console games.

Un- and rezipped rt.jar with WinRAR on ‘Best’ setting. Went from about 32 megs to about 15. Time from starting java to my program window getting displayed is now around 20 seconds. Better, but still far from elegant.

Any more tips on speeding up Java/reducing JRE size?

You can copy the JRE to the user.temp directory, and launch it from there…

:-\

Fastest would be to put the whole JRE in a zip-file (not compressed!) copy that file to the temp dir, extract it (very fast when not compressed) and launch it from there

What version of the JRE are you using? If 5.0_xx, once the JRE is installed on your USB stick, have you run java -Xshare:dump? This will create the class data sharing archive which improves startup at least when the JRE is installed on a hard disk. I would be curious to know whether it also improves startup when the JRE is being run from a different medium.

Using the lastest JRE (1.5.0_06). Tried the share dump on harddisk, USB drive and CD, both with the full JRE and one with a bunch of unnecessary stuff (apache, corba, the optional stuff from readme.txt) removed. Didn’t notice an improvement on any of them, even with -Xshare:on.