¡¾Ô´´¡¿Óýű¾ÊµÏÖ JAVA»·¾³ µÄ×Ô¶¯ÅäÖÃ
[code][0 No.512 bash_codes $ ] cat java_path_setup.sh
#! /bin/bash
# just tested under debian/ubuntu
# to set JAVA ENV
# [email]li-jiahuan@sohu.com[/email]
# java_home
# java_bin
# class_path
if [[ $(id -u) != 0 ]];then
echo "root privilege needed"
exit 127
fi
echo -e "This script will try to set the JAVA enviropment for you
But you neet to download the jdk.bin from java.sun.com or somewhere and
manully install the jdk package first
Sorry that I can not do it for you ...\n"
while :
do
read -p "where is the location of JDK package you have installed:" java_home
if [[ ! -d $java_home ]];then
echo "Can not find JAVA_HOME ..."
continue
fi
if [[ ! -d $java_home/bin ]];then
echo "Can not find JAVA_HOME/bin ..."
continue
fi
if [[ ! -e $java_home/lib/dt.jar ]] || \
[[ ! -e $java_home/lib/tools.jar ]];then
echo "Can not find CLASS_PATH files ..."
continue
fi
break
done
# set for X
cat <<- EOF >> /etc/X11/Xsession.d/90mysource
# JAVA ENV
export JAVA_HOME=$java_home
export PATH=\$PATH:\$JAVA_HOME/bin
export CLASSPATH=./:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib/tools.jar
EOF
# set for shell
cat <<- EOF >> ${HOME}/.profile
# JAVA ENV
export JAVA_HOME=$java_home
export PATH=\$PATH:\$JAVA_HOME/bin
export CLASSPATH=./:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib/tools.jar
EOF
echo -e "Done."
[/code]
Ò³:
[1]