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 is free to download and use for commercial use, but not to redistribute, therefore it is not included in a officially maintained repository.

There are many reasons why you would want to install Oracle Java over OpenJDK. In this tutorial, we will not discuss the differences between the above mentioned implementations.

 

Assumptions

This tutorial assumes that you have an account with DigitalOcean, as well as a Droplet running Debian 7 or Ubuntu 12.04 or above. You will need root privileges (via sudo) to complete the tutorial.

You will need to know whether you are running a 32 bit or a 64 bit OS:

uname -m
  • 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 you 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 JVM monitoring and tools commonly required for server applications.

In this tutorial we will 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 (64 or 32 bits). Use wget to download the archive into your server:

    wget --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u5-b13/jdk-8u5-linux-x64.tar.gz

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 downloaded file.

 

Installing Oracle JDK

In this section, you will need sudo privileges:

    sudo su

The /opt directory is reserved for all the software and add-on packages that are not part of the default installation. Create a directory for your JDK installation:

    mkdir /opt/jdk

and extract java into the /opt/jdk directory:

    tar -zxf jdk-8u5-linux-x64.tar.gz -C /opt/jdk

Verify that the file has been extracted into the /opt/jdk directory.

    ls /opt/jdk
 

Setting Oracle JDK as the default JVM

In our case, 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:

    update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_05/bin/java 100

and

    update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_05/bin/javac 100
 

Verify your installation

Verify that java has been successfully configured by running:

    update-alternatives --display java

and

    update-alternatives --display javac

The output should look like this:

    java - auto mode
link currently points to /opt/jdk/jdk1.8.0_05/bin/java
/opt/jdk/jdk1.8.0_05/bin/java - priority 100
Current '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 100
Current 'best' version is '/opt/jdk/jdk1.8.0_05/bin/javac'.

Another easy way to check your installation is:

    java -version

The output should look like this:

    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)

ubuntu vps 安装java的更多相关文章

  1. ZH奶酪:如何在Ubuntu上安装Java/管理多个JAVA/设置JAVA_HOME

    0.简介 Java的地位及重要性,大家都懂的,很多软件都依赖于jdk,在Ubuntu上安装Java的选择有很多,openJDK,Oracle Jdk... 1.安装默认 JRE/JDK(可选) 这是最 ...

  2. Ubuntu 14 安装Java(JRE、JDK)

    JRE vs OpenJDK vs Oracle JDK JRE(Java Runtime Environment),它是你运行一个基于Java语言应用程序的所正常需要的环境.如果你不是一个程序员的话 ...

  3. Ubuntu 14 安装Java(JRE、JDK)、Maven

    JRE vs OpenJDK vs Oracle JDK JRE(Java Runtime Environment),它是你运行一个基于Java语言应用程序的所正常需要的环境.如果你不是一个程序员的话 ...

  4. 【Ubuntu】安装Java和Eclipse

    1. 安装Java 1> sudo add-apt-repository ppa:webupd8team/java 2> sudo apt-get update 3> sudo ap ...

  5. ubuntu vps 安装 jdk

    Introduction Java is a programming technology originally developed by Sun Microsystems and later acq ...

  6. ubuntu之安装java浏览器插件

    最近搞什么openstack,在浏览器访问远程虚拟机的时候,需要浏览器有支持java.这个之前真没注意过呢, 通过自己的实践写点东西,方便一下你们搞: 1,首先去http://www.java.com ...

  7. ubuntu下安装java和eclipse

    java安装 1 下载jdk http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html 2 ...

  8. ubuntu下安装 java环境

    步骤1:下载jdk 我选择的jdk版本文件: jdk-8u201-linux-x64.tar 官网下载链接 步骤2:创建单独的目录 sudo mkdir /usr/local/java 步骤3:将下载 ...

  9. Ubuntu下安装java

    1.首先到java.com下载最新版本的jdk.下面是jdk8的网址: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-dow ...

随机推荐

  1. CentOS 6 安装 python 2.7 和 mod_wsgi 运行pyocr[tesseract]

    最新版本的tesseract-ocr 3.0.4 需要运行于python2.7版本以上,因此需要升级系统中默认的2.6版本python及Mod_WSGI 1,下载安装Python-2.7.10 > ...

  2. hao.360.cn不停跳....

    最近单位里访问hao.360.cn经常会跳....无限循环,有时跳几十次后才会打开.... 但是,单位里走电信出口部分的电脑就没有问题...同样的电脑(移动出口)的用360浏览器.火狐也问题不大,关键 ...

  3. __get,__set

    __get,__set 为php的magic方法,在类中定义为 public 类型. class UserModel { private $id; public $name; public funct ...

  4. 【转载】[JS]让表单提交返回后保持在原来提交的位置上

    有时候,在网页中点击了页面中的按钮或是刷新了页面后,页面滚动条又 会回到顶部,想看后面的记录就又要拖动滚动条,或者要按翻页键,非常不方便,想在提交页面或者在页面刷新的时候仍然保持滚动条的位置不变,最好 ...

  5. 超实用的JavaScript技巧及最佳实践(上)

    在这篇文章中,作者将会向大家分享JavaScript开发的小技巧.最佳实践等非常实用的内容,不管你是前端开发者还是服务端开发者,都应该来看看这些小技巧,它们绝对会让你受益的. 文中所提供的代码片段都已 ...

  6. codeforce No to Palindromes!(枚举)

    /* 题意:给定一个字符串中没有任何长度>1的回文子串!求按照字典序的该串的下一个字符串 也不包含长度>1的任何回文子串! 思路:从最低位进行枚举,保证第i位 不与 第 i-1位和第 i- ...

  7. [ML] Naive Bayes for Text Classification

    TF-IDF Algorithm From http://www.ruanyifeng.com/blog/2013/03/tf-idf.html Chapter 1, 知道了"词频" ...

  8. LeetCode-Maximum Product of Word Lengths

    Description: Given a string array words, find the maximum value of length(word[i]) * length(word[j]) ...

  9. Direct3D11学习:(二)基本绘图概念和基本类型

    转载请注明出处:http://www.cnblogs.com/Ray1024   一.概述 在正式开始学习D3D11之前,我们必需首先学习必要的基础知识. 在这篇文章中,我们将介绍一下Direct3D ...

  10. xss-跨站脚本攻击-后台传给前端的html标签安全显示

    作用 后台拼接的html字符串传到前端,默认是不安全的,需要告诉前端这个字符串是安全的,可以正常显示html标签. 知识点 1.定义 2 3 <script>      获取session ...