1.centos 5.6安裝及配置JDK環境變數

來源:互聯網
上載者:User

標籤:style   io   os   使用   ar   java   for   strong   檔案   

 一:準備工作 

centos系統(liunx)。

JDK 安裝包:jdk-6u27-linux-i586.bin

MYSQL安裝包:MySQL-5.1.72-1.glibc23.i386.rpm-bundle.tar

 

 

 

二:jdk安裝

 

把JDK 安裝包:jdk-6u27-linux-i586.bin上傳到192.168.1.190的/usr/local/java 下。

 

1:安裝

建立安裝目錄,在/usr/local/java 下建立安裝路徑,並將檔案考到該路徑下: 
# mkdir /usr/local/java

jdk-6u27-linux-i586.bin

 這個是自解壓的檔案,在linux上安裝如下: 
# chmod 755 jdk-6u27-linux-i586.bin (注意--賦許可權)
# ./jdk-6u27-linux-i586.bin (注意,這個步驟一定要在jdk-6u11-linux-i586.bin所在目錄下)
在按提示輸入yes後,jdk被解壓。

出現一行字:Do you aggree to the above license terms? [yes or no]
 安裝程式在問您是否願意遵守剛才看過的許可協議。當然要同意了,輸入"y" 或 "yes" 斷行符號。

 

2:查看檔案。

# cd/usr/local/java

# ls

三:jdk配置環境變數

 

#vi /etc/profile 

 在裡面添加如下內容

export JAVA_HOME=/usr/local/java/jdk1.6.0_27

export JAVA_BIN=/usr/local/java/jdk1.6.0_27/bin

export PATH=$PATH:$JAVA_HOME/bin

export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export JAVA_HOME JAVA_BIN PATH CLASSPATH

 

讓/etc/profile檔案修改後立即生效 ,可以使用如下命令:
# . /etc/profile

注意: . 和 /etc/profile 有空格. 

開啟doc視窗
輸入以下命令。(核心命令如下) 

[[email protected] ~]# ls

[[email protected] ~]# env

[[email protected] etc]# vi profile

[[email protected] etc]# ll profile

-rw-r--r-- 1 root root 1014 Aug 29 18:11 profile

[[email protected] etc]# chmod u+x profile

[[email protected] etc]# ls -l profile

-rwxr--r-- 1 root root 1014 Aug 29 18:11 profile

[[email protected] etc]# vi profile

[[email protected] etc]# cd /usr/local/

bin/     etc/     games/   include/ ivr/     java/    lib/     libexec/ mbox/    prompt/  sbin/    share/   src/     

[[email protected] etc]# cd /usr/local/java/jdk

jdk1.6.0_27/             jdk-6u27-linux-i586.bin  

[[email protected] etc]# cd /usr/local/java/jdk

jdk1.6.0_27/             jdk-6u27-linux-i586.bin  

[[email protected] etc]# cd /usr/local/java/jdk1.6.0_27/

[[email protected] jdk1.6.0_27]# pwd

/usr/local/java/jdk1.6.0_27

[[email protected] jdk1.6.0_27]# vi /etc/profile

 

# /etc/profile

if [ -z "$INPUTRC" -a ! -f "$HOME/.inputrc" ]; then

    INPUTRC=/etc/inputrc

fi

export JAVA_HOME=/usr/local/java/jdk1.6.0_27

export JAVA_BIN=/usr/local/java/jdk1.6.0_27/bin

export PATH=$PATH:$JAVA_HOME/bin

export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export JAVA_HOME JAVA_BIN PATH CLASSPATH

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC

 

for i in /etc/profile.d/*.sh ; do

 

"/etc/profile" 62L, 1246C written

[[email protected] jdk1.6.0_27]# source /etc/profile

[[email protected] jdk1.6.0_27]# java -version

java version "1.6.0_27"

Java(TM) SE Runtime Environment (build 1.6.0_27-b07)

Java HotSpot(TM) Server VM (build 20.2-b06, mixed mode)

[[email protected] jdk1.6.0_27]# ls -l /etc/profile

-rwxr--r-- 1 root root 1246 Sep  1 14:23 /etc/profile

[[email protected] jdk1.6.0_27]# 

 

 

 

 

具體操作:

 

三:修改profile檔案
# etc /usr/profile
export JAVA_HOME=/usr/local/java/jdk1.6.0_27
export JAVA_BIN=/usr/local/java/jdk1.6.0_27/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH

四:退出並儲存vi 下修改的profile檔案
按一下ESC 之後再輸入:rq

出現
E212" can not open file for writing
press enter or type command to continue

1.centos 5.6安裝及配置JDK環境變數

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.