1.在www.sun.com 官网下载完整的jdk 安装包,下载不完全在安装过程可能会遇到如下的错误:
Unpacking...
Checksumming...
1
The download file appears to be corrupted. Please refer
to the Troubleshooting section of the Installation
Instructions on the download page for more information.
Please do not attempt to install this archive file.
2.2复制安装文件至/home/java下
2.3使用"chmod 777"或"chomd +x"向文件添加可执行权限
sudo chomd +x jdk-6u21-linux-i586.bin
2.4运行该文件
sudo ./jdk-6u21-linux-i586.bin
运行后,程序会自动解压缩,并生成相应目录。可以看到如下内容:
For more information on what data Registration collects and
how it is managed and used, see:
http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html
Press Enter to continue.....
Done.
到此,jdk安装已经完成,下面进行环境变量的添加:
3.环境变量的添加:
3.1打开/etc/profile
3.2. 在“umask 022”前添加如下内容:
export JAVA_HOME=/home/yx/Java/jdk1.6.0_21
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH
export CLASSPATH=$CLASSPATH:.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
3.3保存文件并关闭当前窗口
3.4使用source /etc/profile使刚才配置的信息生效
3.5在终端输入java -version进行测试,将看到如下内容:
java version "1.6.0_21"
Java(TM) SE Runtime Environment (build 1.6.0_21-b06)
Java HotSpot(TM) Server VM (build 17.0-b16, mixed mode
到此,Ubuntu 10.10上jdk的安装全部完成。
3.6 如运行 java -version 失败,检查/home/java/jdk1.6.0_21/lib和/home/java/jdk1.6.0_16/jre/lib 目录下是否存在tools.pack 和 rt.pack 两个文件,如存在,将两个文件转换成jar文件:
linux:/home/java/jdk1.6.0_16/bin# unpack200 /home/java/jdk1.6.0_21/lib/tools.pack /home/java/jdk1.6.0_21/lib/tools.jar
linux:/home/java/jdk1.6.0_16/bin# unpack200 /home/java/jdk1.6.0_16/jre/lib/rt.pack /home/java/jdk1.6.0_16/jre/lib /rt.jar
二、tomcat的安装和配置:
1.解压tomcat:运行命令#tar -xf apache-tomcat-6.0.29.tar.gz
2.配置tomcat_home:在/etc/profile文件中加入:TOMCAT_HOME=/usr/apache-tomcat-6.0.29和export JAVA_HOME CLASSPATH PATH TOMCAT_HOME
#set java environment
JAVA_HOME=/usr/jdk1.6.0_21
TOMCAT_HOME=/usr/apache-tomcat-6.0.29
CLASSPATH=.:$JAVA_HOME/lib/tools.jar
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME CLASSPATH PATH TOMCAT_HOME