我有以下脚本用于在Linux操作系统(如CentOS)上下载、安装或更新Java。有没有更好的替代方案?这是一个相当繁琐的脚本,我希望有一个更优雅的解决方案。
###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