1:下載JDK6.0
地址:http://java.sun.com/javase/downloads/index.jsp
我下載的是jdk-6u11-linux-i586.bin
2:用cd命令轉到放jdk檔案的目錄下釋放壓縮包jdk1.6.0_11,
3:用命令:sh jdk-6u11-linux-i586.bin ,一直按斷行符號,直到出現
Do you agree to the above license terms? [yes or no] 輸入:yes
4.完成釋放,運行ls 會發現目前的目錄下產生一個檔案夾:jdk1.6.0_011
5.更改名字,執行命令: mv ./jdk1.6.0_11 ./jdk6.0. 再執行ls,發現名字已經改為jdk6.0.(這一步不做也可以,改名字主要是為了方便)
6. 更改字元集為utf-8:
[root@qudee jdk6.0]# export LANG=en_US
[root@qudee jdk6.0]# export LC_ALL=en_US
7.執行命令: ./bin/java –version 發現已經成功,
java version "1.6.0_11"
Java(TM) SE Runtime Environment (build 1.6.0_11-b05)
Java HotSpot(TM) Server VM (build 1.6.0_011-b05, mixed mode)
再執行java –version
java version "1.4.2"
gcj (GCC) 3.4.6 20060404 (Red Hat 3.4.6-3)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
出錯了,原因是環境變數沒設定好.
8.設定環境變數,執行命令vi /etc/profile
出現編輯框,在
HOSTNAME=`/bin/hostname`
HISTSIZE=1000
底下添加環境變數的路徑:
JAVA_HOME=/opt/java/jdk6.0
CLASS_PATH=$JAVA_HOME/lib:JAVA_HOME/jre/lib:JAVA_HOME/lib/tools.jar:$CLASS_PATH
PATH=$JAVA_HOME/bin:$PATH
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC 在此行後面添加
export CLASS_PATH JAVA_HOME
OK! 按Esc 推出編輯框,再按Shift+;,輸入wq (寫入 儲存並推出)
重新啟動系統。
9.檢查是否安裝成功,輸入命令: java –version
出現資訊:
java version "1.6.0_02"
Java(TM) SE Runtime Environment (build 1.6.0_02-b05)
Java HotSpot(TM) Server VM (build 1.6.0_02-b05, mixed mode)
說明安裝成功!