准备资料:
一、安装jdk
1、把文件jdk-6u10-linux-i586.bin上传到AsianuxServer3服务器上,可以建立一个临时文件夹比如/home/program存放该文件。再把jdk-6u10-linux-i586.bin移动到/opt下准备解压。
cd /home enter
mkdir program enter
mv /home/program/jdk-6u10-linux-i586.bin /opt enter
cd /opt enter
默认上传的文件是没有执行权限的,我们需要给JDK安装文件添加执行权限。
chmod u+x jdk-6u10-linux-i586.bin enter
./ jdk-6u10-linux-i586.bin enter
在安装过程中输入yes,等待安装JDK完毕。
2、安装完毕后设置系统环境变量
JDK的环境变量需要在/etc/profile文件中配置。
vi /etc/profile
在profile文件中插入以下代码:
PATH=$JAVA_HOME/bin:$PATH
JAVA_HOME=/opt/jdk 1.6.0 _10
CLASSPATH=.:$CLASSPATH
export JAVA_HOME CLASSPATH PATH
插入位置在
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
pathmunge () {
if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
}
# Path manipulation
#if [ `id -u` = 0 ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
#fi
pathmunge /usr/X11R6/bin after
unset pathmunge
# No core files by default
ulimit -S -c 0 > /dev/null 2>&1
USER="`id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
HOSTNAME=`/bin/hostname`
HISTSIZE=1000