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. Windows下启动各服务命令

    1. gpedit.msc-----组策略 2. nslookup-------IP地址侦测器 3. explorer-------打开资源管理器 4. logoff---------注销命令 5. ...

  2. 最近想上游戏,弄了个工作室,名"柑谷工作室"

    最近想上游戏,弄了个工作室,名"柑谷工作室",名字取得有点随便,原因是好名字都让狗用了.想当年我用的龙纹工作室,现在龙纹两字也被人用了.人家有硅谷,然后我弄个柑谷,差不多吧.算了, ...

  3. 使用最新的“huihui中文语音库”实现文本转语音功能

    最近一个web项目中,需要进行语音播报,将动态的文字转换为语音(TTS)存为WAV文件后通过web播放给用户.选择了微软所提供的SAPI (The Microsoft Speech API),只需要几 ...

  4. Discuz & UCenter 修改手记 - 2014.12.19

    最近在整JAVA和UCENTER的东西,受限于项目架构需要,无法完全以UCENTER为中心,所以在对接过程中遇到了许多不愉快的事情.经历多番研究,终于解决了其中了两个大问题,现记录下来,以备日后查看. ...

  5. struts2完全捕获404错误的方法

    目前在做一个网络应用程序,struts2 + spring + hibernate,服务器是tomcat.希望用户在IE地址栏乱敲的时候,所敲入的所有未定义的URL都能被程序捕捉到,然后转到一个自制的 ...

  6. 将XmlDocument转换成XDocument

    XmlDocument xml=new XmlDocument(); xml.LoadXml(strXmlText); XmlReader xr=new XmlNodeReader(xml); XDo ...

  7. Unity3D 角色(物体) 移动方法 合集

    1. 简介 在Unity3D中,有多种方式可以改变物体的坐标,实现移动的目的,其本质是每帧修改物体的position. 2. 通过Transform组件移动物体 Transform 组件用于描述物体在 ...

  8. Struts2 之 实现文件上传和下载

    Struts2  之 实现文件上传和下载 必须要引入的jar commons-fileupload-1.3.1.jar commons-io-2.2.jar 01.文件上传需要分别在struts.xm ...

  9. NOIP模拟赛-奶牛晒衣服(dry)

    一.奶牛晒衣服(dry) [问题描述] 在熊大妈英明的带领下,时针和它的同伴生下了许多牛宝宝.熊大妈决定给每个宝宝都穿上可爱的婴儿装.于是,为牛宝宝洗晒衣服就成了很不爽的事情. 圣人王担负起了这个重任 ...

  10. 软件测试之构建测试---BVT

    1. 构建的基本流程: a. 开发人员在他们的个人计算机上编写源代码文件 b. 他们将编写好的文件存放在一个统一集中的地方,构建组将所有的源代码编译成可以在计算机上运行的二进制文件,且用安装工具把各种 ...