首页 > 编程语言 > 详细

linux 安装java shell

时间:2021-05-12 10:03:03      阅读:12      评论:0      收藏:0      [点我收藏+]
#!/bin/bash

# dos2unix *.sh
# Program:
# This program to install and config jdk .
# History:
# 2015/01/28 - add JRE_HOME 

#---------------------------- custom variables ---------------------start
runuser=root
jdk=jdk-6u27-linux-x64.bin

#---------------------------- custom variables ---------------------end

#---------------------------- user check ---------------------start
if [ "`whoami`" != "$runuser" ]; then
    echo "Please re-run ${this_file} as $runuser."
    exit 1
fi
#---------------------------- user check ---------------------end

#---------------------------- function ---------------------start
choice ()
{
clear
echo "
Choose one of the following numbers:
[0]I quit
[1]install jdk
[2]config profile
[3]check java version and path

"
}

pause()
{
	read -n1 -p "Press any key to continue..."
}

#---------------------------- function ---------------------end

#---------------------------- choice ---------------------start

clear
echo "
Choose one of the following numbers:
[0]I quit
[1]install jdk
[2]config profile
[3]check java version and path

"
while
echo "Input your choice: "
read  choice
do
case $choice in
	"0")
		exit 0
		;;
	"1")
		cp $jdk /usr/local
		chmod u+x /usr/local/$jdk
		cd /usr/local
		/usr/local/$jdk
		pause
		choice
		;;
	"2")
cat >> /etc/profile << EOF
export JAVA_HOME=/usr/local/jdk1.6.0_27
export JRE_HOME=/usr/local/jdk1.6.0_27/jre
export PATH=\$JAVA_HOME/bin:\$PATH
EOF
		source /etc/profile
		pause
		choice
		;;
	"3")
		java -version
		echo JAVA_HOME
		pause
		choice
		;;
	*)
		choice
		;;
esac
done

#---------------------------- choice ---------------------end

  

linux 安装java shell

原文:https://www.cnblogs.com/hshy/p/14758106.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!