Ubuntu上解压安装JDK7

apt源中的版本太老了,JDK7已经出了,裸装一下。

转载自:http://blog.sina.com.cn/s/blog_71708d570100zdqt.html

1. Download http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.tar.gz.

2. Decompress the .tar.gz file.

3. Move the JDK files to /usr/lib/jvm/jdk1.7.0 or elsewhere you like.

4. $sudo vim /etc/environment

You will see

PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games”

Change the file as (change the installation path if needed)

PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/jvm/jdk1.7.0/bin”  
CLASSPATH=.:/usr/lib/jvm/jdk1.7.0/lib  
JAVA_HOME=/usr/lib/jvm/jdk1.7.0  

PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/jvm/jdk1.7.0/bin”
CLASSPATH=.:/usr/lib/jvm/jdk1.7.0/lib
JAVA_HOME=/usr/lib/jvm/jdk1.7.0

And then reload .bashrc file:

source ~/.bashrc

5. Run the following commands: 

$sudo update-alternatives –install /usr/bin/java java /usr/lib/jvm/jdk1.7.0/bin/java 300
$sudo update-alternatives –install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0/bin/javac 300
$sudo update-alternatives –install /usr/bin/javap javap /usr/lib/jvm/jdk1.7.0/bin/javap 300
$sudo update-alternatives –install /usr/bin/javadoc javadoc /usr/lib/jvm/jdk1.7.0/bin/javadoc 300

Installation has now done. Run $java -version for a test.

Leave a Reply

Your email address will not be published.