[转]Debian 7 安装 Java JDK

参见http://www.redirecttonull.com/?p=250

原文如下:

Install Java SE 7 SDK on Debian Wheezy

February 19, 2012

Debian ships with OpenJDK by default, but the Sun (now Oracle) Java SDK could be optionally installed using the package sun-java6-jdk. However, Debian have recently removed Oracle Java from their testing (Wheezy) repositories as a result of a new redistribution license (see here), and so it is not possible to install Oracle Java SDK without a little more work.

I really like OpenJDK, but there are several reasons to install the Oracle tools. Clients will tend to use Oracle Java, so that is what I need to test. I also need to test across a number of versions (1.5, 1.6 and 1.7), and also 32-bit and 64-bit architecture.

I have put together this guide which describes all of the stages to successfully install Oracle Java SE SDK on Debian Wheezy. This guide assumes 64-bit Java 7, but it should work for 32-bit and earlier versions of the SDK too.

Download

First you need to download the latest Java SE SDK version. Go to the following link and download the file jdk-7u3-linux-x64.tar.gz (there maybe a later update available when you do this).

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

Install

Once the download has completed extract it into the /opt directory. To do this open a new root terminal and run the following commands:

# cd /opt
# tar -xzvf <path_to_download>/jdk-7u3-linux-x64.tar.gz

Debian already has a pattern for managing different software versions on the same system. This step registers the downloaded version of Java as an alternative, and switches it to be used as the default:

# update-alternatives --install /usr/bin/java java /opt/jdk1.7.0_03/bin/java 1
# update-alternatives --install /usr/bin/javac javac /opt/jdk1.7.0_03/bin/javac 1
# update-alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so mozilla-javaplugin.so /opt/jdk1.7.0_03/jre/lib/amd64/libnpjp2.so 1
# update-alternatives --set java /opt/jdk1.7.0_03/bin/java
# update-alternatives --set javac /opt/jdk1.7.0_03/bin/javac
# update-alternatives --set mozilla-javaplugin.so /opt/jdk1.7.0_03/jre/lib/amd64/libnpjp2.so

That’s it!

Test

To see which version of Java you are now running by default, execute the following command from a terminal:

# java -version
java version "1.7.0_03"
Java(TM) SE Runtime Environment (build 1.7.0_03-b04)
Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode)

To check the browser plugin browse to http://www.java.com/ and click “Do I have Java?”. If everything is installed correctly then you should see the following message:

posted @ 2013-05-23 21:05  ibg  阅读(1019)  评论(0编辑  收藏  举报