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:

de style="margin: 0px; padding: 0px; border: 0px; outline: 0px; background: transparent;"  >uname -m

de>
  • 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:

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.gz

de>

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:

de style="margin: 0px; padding: 0px; border: 0px; outline: 0px; background: transparent;"  >    sudo su

de>

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:

de style="margin: 0px; padding: 0px; border: 0px; outline: 0px; background: transparent;"  >    mkdir /opt/jdk

de>

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/jdk

de>

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

de style="margin: 0px; padding: 0px; border: 0px; outline: 0px; background: transparent;"  >    ls /opt/jdk

de>
 

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:

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 100

de>

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 100

de>
 

Verify your installation

Verify that java has been successfully configured by running:

de style="margin: 0px; padding: 0px; border: 0px; outline: 0px; background: transparent;"  >    update-alternatives --display java

de>

and

de style="margin: 0px; padding: 0px; border: 0px; outline: 0px; background: transparent;"  >    update-alternatives --display javac

de>

The output should look like this:

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 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'.

de>

Another easy way to check your installation is:

de style="margin: 0px; padding: 0px; border: 0px; outline: 0px; background: transparent;"  >    java -version

de>

The output should look like this:

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 安装 jdk的更多相关文章

  1. Ubuntu下安装JDK以及相关配置

    1.查看系统位数,输入以下命令即可 getconf LONG_BIT 2.下载对应的JDK文件,我这里下载的是jdk-8u60-linux-64.tar.gz 3.创建目录作为JDK的安装目录,这里选 ...

  2. 在Ubuntu上安装JDK、Ant、Jmeter和Jenkins

    一.前期准备 1. 在win7下载VMware.Ubuntu(用迅雷下比较快) 2. 安装完VMware后新建虚拟机,选择iso: 3. 具体配置参考如下,至此Ubantu安装完成 二.在Ubuntu ...

  3. Ubuntu下安装JDK图文详解

    很详细的在Ubuntu中安装JDK图文详解教程,我们选择的是jdk1.6.0_30版本.安装文件名为jdk-6u30-linux-i586.bin. 1.复制jdk到安装目录 (1)假设jdk安装文件 ...

  4. Ubuntu上安装jdk,Jboss

    Ubuntu上安装jdk 1.使用wget命令或sft方式从oracle官方下载tar.gz格式的jdk1.7,由于ubuntu不支持rpm安装,需要转换,所以不选择rpm格式的jdk 2.使用tar ...

  5. Ubuntu下安装JDK详细教程

    Ubuntu下安装JDK详细教程 作者:凯鲁嘎吉 - 博客园http://www.cnblogs.com/kailugaji/ Ubuntu版本:Ubuntu-12.04.5-desktop-i386 ...

  6. Ubuntu下安装JDK图文教程详解 jdk-java6-30 .bin 的处理方法

    Ubuntu下安装JDK图文教程详解 jdk-java6-30 .bin 的处理方法: https://blog.csdn.net/mingjie1212/article/details/485250 ...

  7. Ubuntu下安装JDK图文解析

    我们在64位的Ubuntu中安装JDK,选择的是jdk1.6.0_32版本号.安装文件名称为jdk-6u32-linux-x64.bin(这个是64位系统的),假设是32位系统的还须要去官网下载32位 ...

  8. ubuntu下安装JDK并搭建activeMQ

    1.安装JDK,网上有人说activeMQ支持持JDK1.7及以上版本,未实际测试,保险起见我这里直接安装JDK1.7. #apt-get install openjdk--jdk 2.设置环境变量 ...

  9. Linux(ubuntu)下安装JDK、Tomcat

    一.安装jdk 1)首先以root用户登录进去,在根目录下建立opt的目录,我们将下载的东西都放到该目录下去. 2)下载j2sdk ,如jdk-6u31-linux-i586.bin 下载地址如下ht ...

随机推荐

  1. 浅析Java中的final关键字(转载)

    自http://www.cnblogs.com/dolphin0520/p/3736238.html转载 一.final关键字的基本用法 在Java中,final关键字可以用来修饰类.方法和变量(包括 ...

  2. Mosquitto搭建Android推送服务番外篇一:各种报错解决

    文章钢要: 目前笔者在开发搭建Mosquitto服务器,在此期间遇到很多实际问题,所以走了很多弯路,在这里写出来为大家提供一些帮助. 1.安装完成后启动Mosquitto报错 执行mosquitto客 ...

  3. 基因匹配(bzoj 1264)

    Description 基因匹配(match) 卡卡昨天晚上做梦梦见他和可可来到了另外一个星球,这个星球上生物的DNA序列由无数种碱基排列而成(地球上只有4种),而更奇怪的是,组成DNA序列的每一种碱 ...

  4. 第五课 CSS3 and H5 知识点

    概要:CSS3美化样式.自定义字体图标.滤镜设置.CSS3选择器.transform2D转换.新增表单控件.vaild表单验证.表单样式美化等. 属性选择器: E[attr]只使用属性名,但没有确定任 ...

  5. MapReduce工作原理图文详解

    目录:1.MapReduce作业运行流程2.Map.Reduce任务中Shuffle和排序的过程 1.MapReduce作业运行流程 流程示意图: 流程分析: 1.在客户端启动一个作业. 2.向Job ...

  6. 毕业论文中使用的技术—FileReader接口

    用来把文件读入内存,并且读取文件中的数据. FileReader接口提供了一个异步API,使用该API可以在浏览器主线程中异步访问文件系统,读取文件中的数据 FileReader接口的方法 方法名 参 ...

  7. 使用dom4j读取xml连接数据库与之单例模式

    使用dom4j读取xml ,加入jar包 dom4j-1.6.1.jar jaxen-1.1-beta-6.jar public class XmlConfigReader { //懒汉式,延迟加载 ...

  8. jquery 回车事件

    简单地记下jquery实现回车事件,代码如下: 全局: $(document).keydown(function(e){ if(e.keyCode==13){ $(".login-li in ...

  9. 【iOS 使用github上传代码】详解

    [iOS 使用github上传代码]详解 一.github创建新工程 二.直接添加文件 三.通过https 和 SSH 操作两种方式上传工程 3.1https 和 SSH 的区别: 3.1.1.前者可 ...

  10. 循环遍历checkbox按钮,和点击后提示。

    今天做了一个有关checkbox点击的项目,点击checkbox获取这行的数值,然后相加.运用的是jquery和PHP传值. $('input[type=checkbox]').click(funct ...