ubuntu 安裝JDK & eclipse

 

Eclipse

1,下載Eclipse(http://www.eclipse.org/downloads/)的最新版本,因爲我這裏下載的是eclipse-inst-linux64.tar.gz安裝版本。因此跟其餘教程不太同樣:html

2,解壓Eclipse到目錄/opt/,以供全局使用。java

3,在目錄:/opt/eclipse/下,能夠看到一個可執行文件,雙擊便可運行:linux

4,建立桌面快捷方式,以下:vim

  1,在終端中執行以下命令bash

gksudo gedit /usr/share/applications/eclipse.desktop

  2,粘貼並保存以下內容oracle

[Desktop Entry]
Name=Eclipse 4
Type=Application
Exec=/opt/eclipse/eclipse
Terminal=false
Icon=/opt/eclipse/icon.xpm
Comment=Integrated Development Environment
NoDisplay=false
Categories=Development;IDE;
Name[en]=Eclipse

  

JDK

參考:http://blog.csdn.net/snowdream86/article/details/6677450app

1, 下載jdk:(http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html)eclipse-inst-linux64.tar.gz eclipse

2, 解壓安裝:解壓eclipse-inst-linux64.tar.gz 到/usr/lib/jvm/目錄下jvm

3,設置環境變量:vim ~/.bashrc  ,並讓其當即生效:source ~/.bashrcide

export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_79
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

  4, 配置默認JDK版本:

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_79/bin/java 300
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_79/bin/javac 300
sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk1.7.0_79/bin/jar 300 
sudo update-alternatives --install /usr/bin/javah javah /usr/lib/jvm/jdk1.7.0_79/bin/javah 300 
sudo update-alternatives --install /usr/bin/javap javap /usr/lib/jvm/jdk1.7.0_79/bin/javap 300 

sudo update-alternatives --config java

  

系統會列出各類JDK版本,以下所示:

有 3 個候選項可用於替換 java (提供 /usr/bin/java)。

  選擇       路徑                                          優先級  狀態
------------------------------------------------------------
  0            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      自動模式
  1            /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071      手動模式
  2            /usr/lib/jvm/jdk1.7.0_79/bin/java                300       手動模式
* 3            /usr/local/java/jdk1.6.0_45/bin/java             1         手動模式

要維持當前值[*]請按回車鍵,或者鍵入選擇的編號:2
update-alternatives: using /usr/lib/jvm/jdk1.7.0_79/bin/java to provide /usr/bin/java (java) in 手動模式

5, 測試:java -version   

java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
相關文章
相關標籤/搜索