Oracle Java JDK 7 on Ubuntu Linux

Source: Internet
Author: User
Oracle Java JDK 7 on Ubuntu Linux-source or RPM Installation

    • 1. Introduction
    • 2. Download Oracle Java JDK 7
    • 3. Prepare Java's destination directory
    • 4. install Java JDK 7
    • 5. Set system environment
    • 6. installation from RPM package
    • 7. Conclusion
1. Introduction

In the previous article we have discussed how to install openjdk
Java on Ubuntu from the standard Ubuntu repository or Oracle's Java JDK 7 using personal package archives (PPA ). this article will cover installation of Oracle Java JDK 7 from a source package or by converting RPM Java package to the Debian Software Package
Format.

2. Download Oracle Java JDK 7

First, we need to download Oracle Java JDK source package from the official
Oracle website. Navigate to JDK downloads, accept license terms and download
Jdk-7<Version>-Linux-<Architecture>.Tar.gz. Current version of this source package is
Jdk-7u11-linux-x64.tar.gzAnd this is also what we are going to use in this tutorial. store this tarball source package into your home directory or some other arbitrary place.

3. Prepare Java's destination directory

You can use Java by simply extracting it in any directory and then set your path to this location. however, in this article we will install Java into/usr/lib/JVM directory. once we extract Java package to this directory we use this directory and set system's
Environment appropriately to reflect the new Java installation. As a root or with help of
SudoCommand create the directory/usr/lib/JVM:

$ sudo mkdir /usr/lib/jvm
4. install Java JDK 7

The initial installation involves a simple tar file extraction for the Java's source package to/usr/lib/JVM. This can be achieved with the following command:

$ sudo tar -C /usr/lib/jvm -xzf jdk-7u11-linux-x64.tar.gz

This will create a Java directory with a name appropriate to your Java version. For example, in this case it is:

$ ls /usr/lib/jvmjdk1.7.0_11
5. Set system environment

Although we have copied Java to the right location we still need to set up working environment to recognize our new Java directory. If we now test for the Java version we will get error message:

$ java -versionThe program 'java' can be found in the following packages: * default-jre * gcj-4.6-jre-headless * openjdk-6-jre-headless * gcj-4.5-jre-headless * openjdk-7-jre-headlessTry: sudo apt-get install <selected package>

First, we need to check whether there are already some java alternatives installed on the system. To do that we can useUpdate-AlternativesCommand:

$ sudo update-alternatives --list javaupdate-alternatives: error: no alternatives for java.

Currently, we have no other Java installations on the system so let us add our new installation:

$ sudo update-alternatives --install /usr/bin/java java \ /usr/lib/jvm/jdk1.7.0_11/jre/bin/java 1

Do not forget "1" (priority) of the above command. To confirm validity of this new environment settings use again
Update-AlternativesCommand:

$ sudo update-alternatives --list java/usr/lib/jvm/jdk1.7.0_11/jre/bin/java

Or check directly for the Java version:

$ java -versionjava version "1.7.0_11"Java(TM) SE Runtime Environment (build 1.7.0_11-b21)Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)

This confirms that the installation of Oracle Java JDK 7 on your Ubuntu Linux system was installed med correctly.

In case that you have had already installed openjdk Java from the Ubuntu's repository you wowould still need to add your new Oracle Java JDK 7 installation into the system's environment with the above
Update-alternatives -- installCommand. Once you add another Java alternative to your system you can switch between both alternatives as shown in our previous article on how to install

Java on Ubuntu from Ubuntu's PPA.

6. installation from RPM package

The above shoshould provide a clear and easy way to install Oracle Java JDK 7 on your Ubuntu Linux system. Another install alternative is to convert Oracle's official RPM package to Deb and install it with
DpkgCommand as follows:

First download Oracle's official RPM package suited for your architecture and convert it with
AlienCommand.

$ sudo alien --scripts jdk-7u11-linux-x64.rpm jdk_1.7.011-1_amd64.deb generated

This may take a while. Once ready, install this package withDpkgCommand:

$ java -versionThe program 'java' can be found in the following packages:

At this point no Java is available on the system.

$ sudo dpkg -i jdk_1.7.011-1_amd64.deb Selecting previously unselected package jdk.(Reading database ... 48744 files and directories currently installed.)Unpacking jdk (from jdk_1.7.011-1_amd64.deb) ...

Now test for the Java version:

$ java -versionjava version "1.7.0_11"Java(TM) SE Runtime Environment (build 1.7.0_11-b21)Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)
7. Conclusion

Since we have installed Java from the source package the above instruction shoshould work for any Java version including older versions such as Oracle Java JDK 6.

Make sure you tune in to our
RSS and Linux jobs portal to stay informed about the latest opportunities in the field. also visit our
Linux Forum if you want to share your Linux experiences with us or require additional help.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.