Ubuntu 12.04 x64 安裝jdk-7u45-linux-x64.tar.gz過程記錄

Ubuntu 12.04 x64 安裝jdk-7u45-linux-x64.tar.gz過程記錄: html

1.首先下載最新版 jdk 64-bit版 (jdk-7u45-linux-x64.tar.gz) java

從官網下載http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html linux

2.將jdk-7u45-linux-x64.tar.gz拷貝到/opt/java: oracle

sudo mkdir -p /opt/java jvm

sudo cp ~/Downloads/jdk-7u45-linux-x64.tar.gz /opt/java ui

cd /opt/java htm

sudo tar -xzvf jdk-7u45-linux-x64.tar.gz    //解壓縮文件 get

sudo rm jdk-7u45-linux-x64.tar.gz it

3.設置環境變量,
sudo vi /etc/profile io

在文件的最後面增長:

export JAVA_HOME=/opt/java/jdk1.7.0_45

export JRE_HOME=/opt/java/jdk1.7.0_45/jre

export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH

export CLASSPATH=$CLASSPATH:.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib

4.將系統默認的jdk修改過來(可選)

$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_45/bin/java 300

$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_45/bin/javac 300

$ sudo update-alternatives --config java

$ sudo update-alternatives --config javac

5.檢測,輸入java -version

java version "1.7.0_45"

Java(TM) SE Runtime Environment (build 1.7.0_45-b18)

Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)

相關文章
相關標籤/搜索