How do I install Oracle Java JDK 7?

Source: Internet
Author: User
Tags gz file

Http://askubuntu.com/questions/55848/how-do-i-install-oracle-java-jdk-7

There is a similar question on how to install JRE 7.

Install the JDK
    • Download he 32bit or 64bit Linux "compressed binary file"-it has a ".tar.gz" File Extension I. e. "[java-version+-i586.tar.gz" for 32bit and "[java-version+-x64.tar.gz"
    • Uncompress it

      Tar-xvf jdk-7u2-linux-i586.tar.gz(32bit)

      Tar-xvf jdk-7u2-linux-x64.tar.gz(64bit)

JDK 7 package is extracted into./jdk.1.7.0 _ 02 directory. N. B. Check carefully this folder name since Oracle seem to change this occasionally with each update.

    • Now move the JDK 7 directory/Usr/lib
 
Sudo mkdir-P/usr/lib/jvmsudo mV./jdk.1.7.0 _ 02/usr/lib/JVM/jdk1.7.0
    • Now run
Sudo Update-alternatives -- install "/usr/bin/Java" "Java" "/usr/lib/JVM/jdk1.7.0/bin/Java" 1 sudo Update-alternatives -- install "/ usr/bin/javac "" javac ""/usr/lib/JVM/jdk1.7.0/bin/javac "1 sudo Update-alternatives -- install"/usr/bin/javaws "" javaws "/usr/lib/JVM/jdk1.7.0/bin/javaws" 1
    • Correct the permissions of the executables:
 
Sudo chmod A + x/usr/bin/Java sudo chmod A + x/usr/bin/javac sudo chmod A + x/usr/bin/javaws

N. B. Remember-Java JDK has more executables that you can similarly install as abve.Java,Javac,JavawsAre probably the most frequently required.

This answer lists the other executables available.

    • Run
 
Sudo Update-alternatives -- config Java

You will see output similar one below-choose the number of jdk1.7.0-for example3In this list:

 
$ Sudo Update-alternatives -- config javathere are 3 choices for the alternative Java (providing/usr/bin/Java ). selection path priority status ------------------ * 0/usr/lib/JVM/java-6-openjdk/JRE/bin/Java 1061 auto mode1/usr/lib/JVM/java-6-openjdk/JRE/bin/Java 1061 Manual mode2/usr/lib/JVM/Java-6-sun/JRE/bin/Java 63 Manual mode3/usr/lib/JVM/jdk1.7.0/JRE/bin/Java 3 manual modepress enter to keep the current choice [*], or Type Selection number: 3update-alternatives: Using/usr/lib/JVM/jdk1.7.0/JRE/bin/Java to provide/usr/bin/Java (Java) in manual mode.

Check the version of you new JDK 7 installation:

Java-version

Java version "1.7.0" Java (TM) se Runtime Environment (build 1.7.0-b147) Java hotspot (TM) Client VM (build 21.0-b17, mixed mode)

Repeat the above:

 
Sudo Update-alternatives -- config javacsudo Update-alternatives -- config javaws

Enable Mozilla Firefox Plugin:

 
32 bit: ln-S/usr/lib/JVM/jdk1.7.0/JRE/lib/i386/libnpjp2.so ~ /. Mozilla/plugins/64 bit: ln-S/usr/lib/JVM/jdk1.7.0/JRE/lib/amd64/libnpjp2.so ~ /. Mozilla/plugins/

N. B. You can link the plugin (Libnpjp2.so)/Usr/lib/Firefox/plugins/For a system wide installation

Depending on your configuration, you might need to update the apparmor profile for Firefox (or other browsers) in/etc/apparmor. d/export actions/ubuntu-browsers.d/Java

# Replace the two lines: #/usr/lib/JVM/Java-*-sun-1. */JRE/bin/Java {, _ VM} CX-> browser_java, #/usr/lib/JVM/Java-*-sun-1. */JRE/lib/*/libnp *. so CX-> browser_java, # With those (or adapt to your new JDK folder name)/usr/lib/JVM/JDK */JRE/bin/Java {, _ VM} CX-> browser_java,/usr/lib/JVM/JDK */JRE/lib/*/libnp *. so CX-> browser_java,

Then restart apparmor:

 
Sudo/etc/init. d/apparmor restart

Confirm that the JRE has been successful by using the official Oracle website.

For Java 6:

    • How do I install Oracle JDK 6?

If you're on a fresh installation of ubuntu with no previous Java installations, this script automatically the process outlined above if you don't want to type all that into a console. Remember, youStill need to download Java from Oracle's website-- Oracle's links are not wget friendly.

Before using thisMake sureThat this script is in the same directory as the .tar.gz file extension that you downloaded and there areNoFiles that start with jdk-7 in the same folder -- if there are, please move them out of the folder temporarily. Remember to make the script executable, either by doingChmod + x <script's directory>Or right clicking the document, pressing properties, going to the permissions tab, and checking "allow executing file as a program ."

#! /Bin/shtar-xvf jdk-7 * sudo mkdir/usr/lib/jvmsudo mV. /jdk1.7 */usr/lib/JVM/jdk1.7.0sudo Update-alternatives -- install "/usr/bin/Java" "Java" "/usr/lib/JVM/jdk1.7.0/bin/Java "1 sudo Update-alternatives -- install"/usr/bin/javac "" javac ""/usr/lib/JVM/jdk1.7.0/bin/javac "1 sudo Update-alternatives -- install "/usr/bin/javaws" "javaws" "/usr/lib/JVM/jdk1.7.0/bin/javaws" 1 sudo chmod A + x/usr/bin/javasudo chmod A + x/usr/bin/javacsudo chmod A + x/usr/bin/javaws

If you want to install the plugin for Firefox then add this to the end of the script

 
Mkdir ~ /. Mozilla/pluginsln-S/usr/lib/JVM/jdk1.7.0/JRE/lib/amd64/libnpjp2.so ~ /. Mozilla/plugins/sudo/etc/init. d/apparmor restart

Confirm if Java has been properly installed.

 
Java-version

Confirm that the JRE Mozilla plugin has been successful by using the official Oracle website.

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.