Introduction
Java is a programming technology originally developed by Sun Microsystems and later acquired by Oracle. Oracle Java is a proprietary implementation for Java that's free to download and use for commercial use, but not to Redis Tribute, therefore it is not included in a officially maintained repository.
There is many reasons why do you would want to install Oracle Java over OpenJDK. In this tutorial, we'll not discuss the differences between the above mentioned implementations.
Assumptions
This tutorial assumes it has an account with Digitalocean, as well as a Droplet running Debian 7 or Ubuntu 12.04 or Above. You'll need root privileges (via sudo) to complete the tutorial.
You'll need to know whether your is running a + bit or a A-bit OS:
De style= "margin:0px; padding:0px; border:0px; outline:0px; background:transparent; " >uname-mde>
x86_64:64 bit kernel
I686:32 bit kernel
Downloading Oracle Java JDK
Using your Web browser, go to the Oracle Java SE (Standard Edition) website and decide which version of the want to install:
Jdk:java Development Kit. Includes a complete JRE plus tools for developing, debugging, and monitoring Java applications.
Server Jre:java Runtime Environment. For deploying Java applications on servers. Includes tools for the JVM monitoring and tools commonly required for server applications.
In this tutorial we'll be installing the JDK Java SE development Kit 8 x64 bits. Accept the license and copy the download link into your clipboard. Remember to choose the right tar.gz (.) Use wget to download the archive into your server:
De style= "margin:0px; padding:0px; border:0px; outline:0px; background:transparent; " > wget--header "Cookie:oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/ Jdk/8u5-b13/jdk-8u5-linux-x64.tar.gzde>
Oracle does not allow downloads without accepting their license, therefore we needed to modify the header of our request. Alternatively, you can just download the compressed file using your browser and manually upload it using a SFTP/FTP client .
Always get the latest version from Oracle's website and modify the commands from this tutorial accordingly to your Downloa Ded file.
Installing Oracle JDK
In this section, you'll need sudo privileges:
De style= "margin:0px; padding:0px; border:0px; outline:0px; background:transparent; " > sudo sude>
The/opt directory is reserved for all the software and add-on packages This is a part of the default installation. Create a directory for your JDK installation:
De style= "margin:0px; padding:0px; border:0px; outline:0px; background:transparent; " > mkdir/opt/jdkde>
And extract Java into THE/OPT/JDK directory:
De style= "margin:0px; padding:0px; border:0px; outline:0px; background:transparent; " > tar-zxf jdk-8u5-linux-x64.tar.gz-c/opt/jdkde>
Verify that the file had been extracted into the/opt/jdk directory.
De style= "margin:0px; padding:0px; border:0px; outline:0px; background:transparent; " > ls/opt/jdkde>
Setting Oracle JDK as the default JVM
The Java executable is located under/opt/jdk/jdk1.8.0_05/bin/java. To set it as the default JVM in your machine run:
De style= "margin:0px; padding:0px; border:0px; outline:0px; background:transparent; " > update-alternatives--install/usr/bin/java java/opt/jdk/jdk1.8.0_05/bin/java 100de>
and
De style= "margin:0px; padding:0px; border:0px; outline:0px; background:transparent; " > update-alternatives--install/usr/bin/javac javac/opt/jdk/jdk1.8.0_05/bin/javac 100de>
Verify Your Installation
Verify that Java have been successfully configured by running:
De style= "margin:0px; padding:0px; border:0px; outline:0px; background:transparent; " > update-alternatives--display javade>
and
De style= "margin:0px; padding:0px; border:0px; outline:0px; background:transparent; " > update-alternatives--display javacde>
The output should:
De style= "margin:0px; padding:0px; border:0px; outline:0px; background:transparent; " > java-auto mode link currently points To/opt/jdk/jdk1.8.0_05/bin/java /opt/jdk/jdk1.8.0_05/bin/ Java-priority "Best " version is '/opt/jdk/jdk1.8.0_05/bin/java '. Javac-auto mode link currently points To/opt/jdk/jdk1.8.0_05/bin/javac /opt/jdk/jdk1.8.0_05/bin/javac- Priority "Best " version is '/opt/jdk/jdk1.8.0_05/bin/javac ' .de>
Another easy-to-check your installation is:
De style= "margin:0px; padding:0px; border:0px; outline:0px; background:transparent; " > java-versionde>
The output should:
De style= "margin:0px; padding:0px; border:0px; outline:0px; background:transparent; " > java Version "1.8.0_05" Java (tm) SE Runtime Environment (build 1.8.0_05-b13) Java HotSpot (tm) 64-bit Server VM (build 25.5-b02, mixed mode) de>
Ubuntu VPS Installation JDK