在没有提示的情况下在Linux / CentOS上安装和升级Java

时间:2010-11-20 21:21:49

标签: java linux installer centos

我有以下脚本在Linux OS上下载,安装或更新Java,例如CentOS。 还有比周围更好的东西吗?这是一个非常麻烦的脚本,我想要一个更优雅的解决方案。

###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  

1 个答案:

答案 0 :(得分:2)

“改进”可以使用yes代替echo y >answers.txt...< answers.txt

使用当前0X中的下一个数字(如果oracle不会更改分发命名约定)检查是否有更新可用,然后下载并安装它。但我不确定它真的值得。