I have the scripts below to download, install or update Java on Linux OS such as CentOS. Is there anything better than that around? It is a quite cumbersome script and I'd like a more elegant solution.
###INSTALL
wget http://www.java.net/download/jdk7/binaries/jdk-7-ea-bin-b96-linux-x64-03_jun_2010.bin
chmod a+x jdk-7-ea-bin-b96-linux-x64-03_jun_2010.bin
echo y > answers.txt
./jdk-7-ea-bin-b96-linux-x64-03_jun_2010.bin < answers.txt &>/dev/null
mkdir /jdk7
mv /root/jdk1.7.0 /jdk7
ln -sf /jdk7/bin/java /usr/bin/java
rm -f jdk-7-ea-bin-b96-linux-x64-03_jun_2010.bin
###UPGRADE
wget http://www.java.net/download/jdk7/binaries/jdk-7-ea-bin-b117-linux-x64-04_nov_2010.bin
chmod a+x jdk-7-ea-bin-b117-linux-x64-04_nov_2010.bin
echo y > answers.txt
rm -rf /jdk7
./jdk-7-ea-bin-b96-linux-x64-03_jun_2010.bin < answers.txt &>/dev/null
mv /root/jdk1.7.0 /jdk7
ln -sf /jdk7/bin/java /usr/bin/java
rm -f jdk-7-ea-bin-b96-linux-x64-03_jun_2010.bin
An "improvement" can be using yes
instead of echo y >answers.txt
and ...< answers.txt
.
It may worth to check if an update is available using the next number from current 0X
(in case if oracle won't change distr naming convention) and then download and install it. But I'm not sure it really worths.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With