Linux 系统是自带有java的,叫OpenJDK。你可以自己如下查看你的JDK版本。
[root@localhost **]# java -version
java version "1.6.0_22"
OpenJDK Runtime Environment (IcedTea6 1.10.1) (fedora-57.1.10.1.fc15-i386)
OpenJDK Client VM (build 20.0-b11, mixed mode)
接下来就是到sun 官网上下载JDK,找到系统对应的版本或者你想要的版本,因为需要我这里下载的是jdk-6u33-linux-i586-rpm.bin 文件。下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk6-downloads-1637591.html
下载完JDK 后,到下载目录给当前用户赋予执行权限
[root@localhost Downloads]# chmod +x jdk-6u33-linux-i586-rpm.bin
然后输入“./jdk-6u33-linux-i586-rpm.bin”执行解压及安装操作
[root@localhost Downloads]# ./jdk-6u33-linux-i586-rpm.bin
Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).
inflating: jdk-6u33-linux-i586.rpm
inflating: sun-javadb-common-10.6.2-1.1.i386.rpm
inflating: sun-javadb-core-10.6.2-1.1.i386.rpm
inflating: sun-javadb-client-10.6.2-1.1.i386.rpm
inflating: sun-javadb-demo-10.6.2-1.1.i386.rpm
inflating: sun-javadb-docs-10.6.2-1.1.i386.rpm
inflating: sun-javadb-javadoc-10.6.2-1.1.i386.rpm
Preparing... ############################# [100%]
...................
待提示
Press Enter to continue.....
这时回车即可。
接下来可以卸载自带的OpenJDK了:
[root@localhost **]# rpm -qa|grep jdk
会粗线你现在拥有的两个版本的java,
jdk-1.6.0_33-fcs.i586
java-1.6.0-openjdk-1.6.0.0-57.1.10.1.fc15.i686
接着:
root@localhost **]# yum -y remove java java-1.6.0-openjdk-1.6.0.0-57.1.10.1.fc15.i686
Loaded plugins: langpacks, presto, refresh-packagekit
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package java-1.6.0-openjdk.i686 1:1.6.0.0-57.1.10.1.fc15 will be erased
--> Processing Dependency: java-1.6.0-openjdk >= 1:1.6.0.0-55 for package: icedtea-web-1.0.2-2.fc15.i686
...........
Dependency Removed:
icedtea-web.i686 0:1.0.2-2.fc15
Complete!
沃的安装好了就可以终端输入java 以及 javac并显示出相关信息了,并没有配置环境变量,需要的话去搜搜一大堆。
Debian(Wheezy)安装Java环境/替换OpenJDK为SUN JDK:http://www.linuxdiyf.com/linux/7023.html
Ubuntu下搭建Android环境-安装sun jdk:http://www.linuxdiyf.com/linux/1829.html