1.下载jdk http://www.oracle.com/technetwork/java/javase/downloads/jdk6downloads-1902814.html

2.上传到linux下

   
   
   
   
  1. [root@localhost ~]# rz 
  2. rz waiting to receive. 
  3. Starting zmodem transfer.  Press Ctrl+C to cancel. 
  4. Transferring jdk-6u29-linux-i586-rpm.bin... 
  5.   100%   78780 KB 3751 KB/s 00:00:21       0 Errors 

3.赋予执行权限

   
   
   
   
  1. [root@localhost ~]# chmod +x jdk-6u29-linux-i586-rpm.bin 

4.安装

   
   
   
   
  1. [root@localhost ~]# ./jdk-6u29-linux-i586-rpm.bin 
  2. Unpacking... 
  3. Checksumming... 
  4. Extracting... 
  5. UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu). 
  6.   inflating: jdk-6u29-linux-i586.rpm  
  7.   inflating: sun-javadb-common-10.6.2-1.1.i386.rpm  
  8.   inflating: sun-javadb-core-10.6.2-1.1.i386.rpm  
  9.   inflating: sun-javadb-client-10.6.2-1.1.i386.rpm  
  10.   inflating: sun-javadb-demo-10.6.2-1.1.i386.rpm  
  11.   inflating: sun-javadb-docs-10.6.2-1.1.i386.rpm  
  12.   inflating: sun-javadb-javadoc-10.6.2-1.1.i386.rpm  
  13. Preparing...                ########################################### [100%] 
  14.    1:jdk                    ########################################### [100%] 
  15. Unpacking JAR files... 
  16.         rt.jar... 
  17.         jsse.jar... 
  18.         charsets.jar... 
  19.         tools.jar... 
  20.         localedata.jar... 
  21.         plugin.jar... 
  22.         javaws.jar... 
  23.         deploy.jar... 
  24. Installing JavaDB 
  25. Preparing...                ########################################### [100%] 
  26.    1:sun-javadb-common      ########################################### [ 17%] 
  27.    2:sun-javadb-core        ########################################### [ 33%] 
  28.    3:sun-javadb-client      ########################################### [ 50%] 
  29.    4:sun-javadb-demo        ########################################### [ 67%] 
  30.    5:sun-javadb-docs        ########################################### [ 83%] 
  31.    6:sun-javadb-javadoc     ########################################### [100%] 
  32.  
  33. Java(TM) SE Development Kit 6 successfully installed. 
  34.  
  35. Product Registration is FREE and includes many benefits: 
  36. * Notification of new versions, patches, and updates 
  37. * Special offers on Oracle products, services and training 
  38. * Access to early releases and documentation 
  39.  
  40. Product and system data will be collected. If your configuration 
  41. supports a browser, the JDK Product Registration form will 
  42. be presented. If you do not register, none of this information 
  43. will be saved. You may also register your JDK later by 
  44. opening the register.html file (located in the JDK installation 
  45. directory) in a browser. 
  46.  
  47. For more information on what data Registration collects and 
  48. how it is managed and used, see: 
  49. http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html 
  50.  
  51. Press Enter to continue..... 
  52.  
  53. Done. 

5.验证安装是否成功(好吧,显示还是系统自带的jdk,有些软件识别不到系统的,所有有时自己安装还是很有必要的)

   
   
   
   
  1. [root@localhost ~]# java -version 
  2. java version "1.4.2" 
  3. gij (GNU libgcj) version 4.1.2 20080704 (Red Hat 4.1.2-46) 
  4.  
  5. Copyright (C) 2006 Free Software Foundation, Inc. 
  6. This is free software; see the source for copying conditions.  There is NO 
  7. warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 

6.配置环境变量
系统默认把jdk安装到 /usr/java/jdk1.6.0_29 目录下(找了N次,还是没找到如何把jdk安装到自己指定的目录下)

   
   
   
   
  1. [root@localhost ~]# vi /etc/profile 

在文件的末尾添加

   
   
   
   
  1. #set Java Environment 
  2. export JAVA_HOME=/usr/java/jdk1.6.0_29 
  3. export PATH=$JAVA_HOME/bin:$PATH 
  4. export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar 

执行命令(立即生效命令,否则重启后生效)

   
   
   
   
  1. [root@localhost ~]# source /etc/profile 

检验成功与否

   
   
   
   
  1. [root@localhost ~]# java -version 
  2. java version "1.6.0_29" 
  3. Java(TM) SE Runtime Environment (build 1.6.0_29-b11) 
  4. Java HotSpot(TM) Client VM (build 20.4-b02, mixed mode, sharing)