Ubuntu 11.10 安装 Sun JDK 7

编程技术  /  houtizong 发布于 3年前   76

一直想使用Sun JDK7来试试它的新功能,但是Ubuntu 11.10的apt-get只能安装OpenJDK,于是乎下载了一个JDK7,解压缩后设置好了JAVA_HOME,也把$JAVA_HOME/bin放到了$PATH下。结果java -version仍然是OpenJDK的……

我心就凉了。

是不是2个java在$PATH中冲突了?于是sudo apt-get autoremove openjdk-6-jre-headless掉OpenJDK,再次java,结果提示没有找到java……

我心就拔凉拔凉的了。

然后google了一圈发现了这篇文章

http://diegobenna.blogspot.com/2011/01/install-jdk-6-update-21-in-ubuntu-1010.html 需翻 墙。

看了一半我发现了/etc/alternatives,以前在找OpenJDK的时候发现java命令是连接到这个文件夹然后才连接到真正的安装目录的,当时忽略了这个事实,恍然大悟中……

 

 

JDK (Java Development Kit) is a software that provides development tools for creating Java programs.

Installation


First we must download the package from the java website, select your platform, in our case Linux:



http://www.oracle.com/technetwork/java/javase/downloads/index.html

Here we go down the file "jdk-6u21-linux-i586.bin" to any folder, then leave where appropriate.

Now we have to give execute permissions:
sudo chmod +x jdk-6u23-linux-i586.bin

and install:
sudo ./jdk-6u23-linux-i586.bin

Now move the generated folder to a more appropriate directory:
sudo mv jdk1.6.0_23/ /usr/local

We set the new Java as one of the alternatives "java"
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/jdk1.6.0_23/bin/java" 1

Now we set the "new alternative" as real Java. This step makes the sun is the version used by default:
sudo update-alternatives --set java /usr/local/jdk1.6.0_23/bin/java

Now we do the same steps above for javac:

sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/jdk1.6.0_23/bin/javac" 1
sudo update-alternatives --set javac /usr/local/jdk1.6.0_23/bin/javac



Now verify that everything works properly. Open the console and type:
java -version

If all is well, you should return the following:

java version "1.6.0_23"
Java (TM) SE Runtime Environment (build 1.6.0_23-B06)
Java HotSpot (TM) Client VM (build 17.0-b16, mixed mode, sharing)


For javac:
javac -version

If all is well back:
javac 1.6.0_23

If you have other installations of java / javac can be configured using the following commands:
sudo update-alternatives --config java
sudo update-alternatives --config javac


Also if you want setear JRE_HOME JAVA_HOME or as environment variables, we must go to:
sudo gedit /etc/environment

Here we record the routes where we have installed Java, in our case is as follows:
JAVA_HOME = "/usr/local/jdk1.6.0_23/bin/" (add)
JRE_HOME = "/usr/local/jdk1.6.0_23/jre" (add)
PATH ="...(other routes):$JAVA_HOME:$JRE_HOME (edit)


With this we finish the installation.

 

还有一篇文章是说安装tomcat的:

http://diegobenna.blogspot.com/2011/01/install-tomcat-7-in-ubuntu-1010.html

请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!

留言需要登陆哦

技术博客集 - 网站简介:
前后端技术:
后端基于Hyperf2.1框架开发,前端使用Bootstrap可视化布局系统生成

网站主要作用:
1.编程技术分享及讨论交流,内置聊天系统;
2.测试交流框架问题,比如:Hyperf、Laravel、TP、beego;
3.本站数据是基于大数据采集等爬虫技术为基础助力分享知识,如有侵权请发邮件到站长邮箱,站长会尽快处理;
4.站长邮箱:[email protected];

      订阅博客周刊 去订阅

文章归档

文章标签

友情链接

Auther ·HouTiZong
侯体宗的博客
© 2020 zongscan.com
版权所有ICP证 : 粤ICP备20027696号
PHP交流群 也可以扫右边的二维码
侯体宗的博客