Monday, October 24, 2011

Install Oracle JDK 7 on Ubuntu 11.10

Download JDK7 on http://www.oracle.com/technetwork/java/javase/downloads/index.html. The most updated is Java SE 7u1.

Follow the steps to Installation the JDK on Linux Platforms, http://download.oracle.com/javase/7/docs/webnotes/install/linux/linux-jdk.html.
eg. This procedure installs the Java Development Kit (JDK) for 32-bit Linux, using an archive binary file (.tar.gz).

These instructions use the following file:

jdk-7u<version>-linux-i586.tar.gz
1. Download the file. Before the file can be downloaded, you must accept the license agreement. The archive binary can be installed by anyone (not only root users), in any location that you can write to. However, only the root user can install the JDK into the system location.

2. Change directory to the location where you would like the JDK to be installed. Move the .tar.gz archive binary to the current directory.

3. Unpack the tarball and install the JDK.

% tar zxvf jdk-7u<version>-linux-i586.tar.gz
The Java Development Kit files are installed in a directory called jdk1.7.0_<version> in the current directory.

4. Delete the .tar.gz file if you want to save disk space.


Up to now, you have downloaded and installed JDK7 on your machine, but not yet installed in your system!

In Terminal, type the command to install the java alternative.
$sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0/bin/javac 1

Where:
  • /usr/lib/jvm/ is the directory the JDK installed, on step 2; such that javac should be at /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0/bin/javac.
  • The last number, 1, is an integer of "priority"; it should be work on any integer number.


Finally, may be you have to config your javac alternative, if you have more than one javac installed.
$sudo update-alternatives --config javac

Note: Up to this minute, only JDK 5 and JDK 6 are officially supported for Android development, according to Android SDK document: System Requirements. May be, it will be officially support JDK 7 in short future.

1 comment:

  1. this could be easier

    http://forum.xda-developers.com/showpost.php?p=19446284&postcount=62

    ReplyDelete