IT业行者,行者无疆
分类: LINUX
2011-05-04 20:00:33
(注:本文安装介绍比较有实用价值!)
安装
1. 去 下载一个Linux Platform的JDK,建议下载RPM自解压格式的(RPM in self-extracting file,j2sdk-1_4_2_06-linux-i586-rpm.bin);
2. 上载到Linux服务器上,在shell下执行命令:
[root@LinuxServer rpm]# chmod 755 j2sdk-1_4_2_06-linux-i586-rpm.bin [root@LinuxServer rpm]# ./j2sdk-1_4_2_06-linux-i586-rpm.bin |
Sun Microsystems, Inc. Binary Code License Agreement for the JAVATM 2 SOFTWARE DEVELOPMENT KIT (J2SDK), STANDARD EDITION, VERSION 1.4.2_X … Do you agree to the above license terms? [yes or no]yes Unpacking... Checksumming... 0 0 Extracting... UnZipSFX 5.40 of 28 November 1998, by Info-ZIP (Zip-Bugs@lists.wku.edu). inflating: j2sdk-1_4_2_06-linux-i586.rpm Done. |
[root@LinuxServer rpm]#rpm –ivh j2sdk-1_4_2_06-linux-i586.rpm Preparing... ########################################### [100%] 1:j2sdk ########################################### [100%] |
附加 :如果是tar.gz等格式的,直接解压,放到USR/JAVA目录,然后设置下面环境变量就可以了
4. 设置环境变量
通常都喜欢用export命令直接在shell下设置
[root@LinuxServer rpm]# export JAVA_HOME=/usr/java/j2sdk1.4.2_06 [root@LinuxServer rpm]# export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar [root@LinuxServer rpm]# export PATH=$PATH:$JAVA_HOME/bin |
[root@LinuxServer rpm]#vi .bashrc set JAVA_HOME=/usr/java/j2sdk1.4.2_06 export JAVA_HOME set PATH=$PATH:$JAVA_HOME/bin export PATH set CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export CLASSPATH |
[root@LinuxServer rpm]# echo $JAVA_HOME /usr/java/j2sdk1.4.2_06/ [root@LinuxServer rpm]# echo $CLASSPATH /usr/java/j2sdk1.4.2_06/lib/dt.jar:/usr/java/j2sdk1.4.2_06/lib/tools.jar [root@LinuxServer rpm]# echo $PATH /usr/java/j2sdk1.4.2_06/bin/:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin [root@LinuxServer rpm]# -version version "1.4.2_06" (TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-b03) HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode) |
[root@LinuxServer rpm]#vi test.java class test { public static void main(String[] args) { System.out.println("Hello World!"); } } |
[root@LinuxServer text]# javac test.java [root@LinuxServer text]# test Hello World! |
[root@LinuxServer root]# vi /home/longware/.bashrc set JAVA_HOME=/usr/java/j2sdk1.4.2_06 export JAVA_HOME set PATH=$PATH:$JAVA_HOME/bin export PATH set CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export CLASSPATH |
7. 至此,Linux上JDK的安装完毕。
卸载
卸载默认的:
用root用户登陆到系统,打开一个终端输入
# rpm -qa|grep gcj
显示内容其中包含下面两行
# java-1.4.2-gcj-compat-1.4.2.0-27jpp
# java-1.4.2-gcj-compat-devel-l.4.2.0-27jpp
卸载
# rpm -e java-1.4.2-gcj-compat-devel-l.4.2.0-27jpp
# rpm -e java-1.4.2-gcj-compat-l.4.2.0-27jpp
卸载其他自己安装的JDK就直接用rpm -e