ubuntu 安装JDK & eclipse
Eclipse
1,下载Eclipse(http://www.eclipse.org/downloads/)的最新版本,由于我这里下载的是eclipse-inst-linux64.tar.gz安装版本。所以跟其他教程不太一样:
2,解压Eclipse到目录/opt/,以供全局使用。
3,在目录:/opt/eclipse/下,可以看到一个可执行文件,双击即可运行:
4,创建桌面快捷方式,如下:
1,在终端中执行如下命令
gksudo gedit /usr/share/applications/eclipse.desktop
2,粘贴并保存如下内容
[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/6677450
1, 下载jdk:(http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html)eclipse-inst-linux64.tar.gz
2, 解压安装:解压eclipse-inst-linux64.tar.gz 到/usr/lib/jvm/目录下
3,设置环境变量:vim ~/.bashrc ,并让其立即生效:source ~/.bashrc
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)