2012年5月17日 星期四

Ubuntu 安裝 JAVA6

安裝Java
關閉所有視窗,同時按下Ctrl + Alt + T 打開終端畫面,
接著安裝JDK,下列的方式是安裝1.6.x版本。

Installing the JDK
下載  jdk-6uXX-linux-x64.bin
$ sudo apt-get purge openjdk*
$ chmod +x jdk-6u32-linux-x64.bin  <--將bin檔設定可執行
$ ./jdk-6u32-linux-x64.bin
$ sudo mv jdk1.6.0_32 /usr/lib/jvm/
Install new java source in system:
$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_32/bin/javac 1
$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_32/bin/java 1
Choose default java:
$ sudo update-alternatives --config javac   <--設定預設Javac
There are 2 choices for the alternative javac (providing /usr/bin/javac).

  Selection    Path                                  Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-7-oracle/bin/javac   1         auto mode
  1            /usr/lib/jvm/java-7-oracle/bin/javac   1         manual mode
  2            /usr/lib/jvm/jdk1.6.0_32/bin/javac     1         manual mode

Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/jdk1.6.0_32/bin/javac to provide /usr/bin/javac (javac) in manual mode.

$ sudo update-alternatives --config java  <--設定預設Java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                 Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-7-oracle/bin/java   1         auto mode
  1            /usr/lib/jvm/java-7-oracle/bin/java   1         manual mode
  2            /usr/lib/jvm/jdk1.6.0_32/bin/java     1         manual mode

Press enter to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/jdk1.6.0_32/bin/java to provide /usr/bin/java (java) in manual mode.

安裝完成後執行java -version指令看到如下訊息出現表示安裝完成。
$ java -version
java version "1.6.0_32"
Java(TM) SE Runtime Environment (build 1.6.0_32-b05)
Java HotSpot(TM) 64-Bit Server VM (build 20.7-b02, mixed mode)




參考:http://cheng-min-i-taiwan.blogspot.com/2012/05/ubuntu-1204-lts-android-sdk.html

沒有留言: