Sometimes (yes it does happen), you need to install the JDK from SUN automatically (without having to answer yes/no to the license). Why? For example in a Kick Start script to auto-install the JDK.
And so to do this, here a bash & perl script for this exact purpose. This script works only with the .bin install package that you download from SUN’s website.
#!/bin/bash jdkBinFile=$1 echo $1 # just spew out the agreement perl -p -i -e 's/^more/cat/g' $1 # set the 'agreed' value for jdk 1.5 perl -p -i -e 's/\s+agreed=$/agreed=1/g' $1 # set the agree value for jdk 1.6 perl -p -i -e 's/`agree`/yes/g' $1 # do not call the register_jdk method perl -p -i -e 's/\s+register_JDK/#register_JDK/g' $1 # and now run the installation bash $1
How to
Create a new script file called autoinstall.sh
containing the above script. and run it as follows:
$ cd /install/to/directory $ autoinstall.sh /my/downloads/jdk-6u16-linux-x64.bin