views:

446

answers:

1

I am trying to bundle java as a part of a java product that should be installed silently with a single click and are having some issues:

My installation has the following requirements: Has no be silent and require no user input or action excpect a doubleclick on the installation file (no configuration and post install steps) Has to setup java so that JAVA_HOME points to a Java SE installation with a server jvm

Is this at all possible to do this on a win32 system with sun java installers? I know that by default the jre does not contian a server jvm. But even when installing the jdk the public jre which is installed (and mapped to JAVA_HOME) does not contain a server jvm. In sun own README file (Sun README) they suggest copying the files:

jre\bin\server\ On Microsoft Windows platforms, the JDK includes both the Java HotSpot(TM) Server VM and Java HotSpot Client VM. However, the Java SE Runtime Environment for Microsoft Windows platforms includes only the Java HotSpot Client VM. Those wishing to use the Java HotSpot Server VM with the Java SE Runtime Environment may copy the JDK's jre\bin\server folder to a bin\server directory in the Java SE Runtime Environment.

But this solution is difficult to automate gracefully in a silent install. There has to be a better way to do this without repackaging the entire java distrubution. Has anyone encountered the same problem and come up with a more elegant solution?

+1  A: 

For the past years, I manage Java like this: I download the installer, install it somewhere, package all files into a ZIP and then use that ZIP file to deploy Java anywhere. The installer will leave a lot of stuff in the registry and %WinDir%, etc. which you don't really need. This also allows me to move some files around (like the bin\server\jvm.dll or security related settings).

That way, I can even embed Java inside the application directory, independent of any already installed version of Java.

Just set JAVA_HOME in a small batch script before starting your application and you're good. You can use %~dp0 to make it completely position independent (%~dp0 expands to the path leading to the batch file).

Aaron Digulla
"The installer will leave a lot of stuff in the registry and %WinDir%, etc. which you don't really need." - is this well-documented behavior, or merely based on experience? What if this behavior changes between installer releases? Zipping the whole JRE like this sounds attracting and scary at the same time.
Joonas Pulakka
I'm not sure it's documented somewhere but I'm pretty sure that Sun can't change this behavior. The registry keys are only there to make it easier for external code to locate the default JVM. They are not necessary for Java to work. I agree it takes a leap of faith :)
Aaron Digulla
Does anyone know the reason you have to jump through hoops to get a working server jvm on windows? I fail to see the logic why the jre on linux has a server jvm installed by default when the windows jre does not.
Mans
Windows is a desktop OS, Linux is a server OS ... most of the time. So it makes sense to make this the default. Also, server admins should know what they're doing while normal users might get confused why Java is installing a server VM on their computer.
Aaron Digulla