Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing and Upgrading Java on Linux / CentOS without prompts

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  
like image 373
MatBanik Avatar asked Nov 20 '10 21:11

MatBanik


1 Answers

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.

like image 79
khachik Avatar answered Nov 12 '22 13:11

khachik