在 Linux / CentOS 上无提示安装和升级 Java

发布于 2024-10-04 06:07:54 字数 919 浏览 1 评论 0原文

我有以下脚本可以在 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  

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  

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

三寸金莲 2024-10-11 06:07:54

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

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文