ubuntu vps 安装java

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

时间: 2024-11-03 03:59:11

ubuntu vps 安装java的相关文章

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

0.简介 Java的地位及重要性,大家都懂的,很多软件都依赖于jdk,在Ubuntu上安装Java的选择有很多,openJDK,Oracle Jdk... 1.安装默认 JRE/JDK(可选) 这是最简单的方式,首先更新package index: sudo apt-get update 查看一下当前机器上是否安装了java: java -version 如果你看到“The program java can be found in the following packages”,那表示还没有安装

ubuntu下安装Java和tomcat

ubuntu 安装jdk 的两种方式: 使用ppa/源方式安装 1 安装jre 打开终端,使用下面的命令安装JRE : sudo apt-get install default-jre 2 安装OpenJDK 在Ubuntu和Linux Mint上安装OpenJDK 在终端,使用下面的命令安装OpenJDK Java开发工具包: sudo apt-get install default-jdk 特殊地, 如果你想要安装Java 8, Java 7或者Java 6等等,你可以使用openjdk-7

【Ubuntu】安装Java和Eclipse

1. 安装Java 1> sudo add-apt-repository ppa:webupd8team/java 2> sudo apt-get update 3> sudo apt-get install Oracle-java8-installer 4> 查看Java版本: javac -version 5> 设置 Java 8 环境变量: sudo apt-get install oracle-java8-set-default 2. 安装Eclipse 1>

Ubuntu 下安装 java jdk

一.下载jdk 下载地址  http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 建议下载tar.gz格式 二.安装 1.解压到指定目录 找到你下载的安装包,解压到指定目录 命令  tar zxvf jdk-8u60-linux-i586.tar.gz -c /opt/       (这里 -c  /opt/为解压路径) ==>查看是否解压成功 cd  /opt/ 后ls 2.配置环

ubuntu vps 安装 jdk

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, th

[zhuan]Ubuntu里面安装Java和Eclipse(配置)

一.JAVA 先贴命令:        cd appsource/        mkdir java        ls l        sudo tar -zxvf jdk-7u67-linux-x64.tar.gz -C ./java/        cd java        sudo mv ./java  /usr/lib/        cd /usr/lib/        ls -l        cd java         ls -l        cd jdk1.7.

Ubuntu下安装java环境

1,在官网中下载 2,通过xshell将压缩包传到虚拟机中的 /usr/local/ 目录下 3 cd /usr/local 4 ls tar zxvf jdk-7u79-linux-x64.tar.gz 注意:这里解压tar.gz在下一篇随笔中会总结它的使用方法 5 cd jdk1.7.0_79/ pwd 复制产生的目录: 6 vi profile 在vi编辑器中插入: 7 source /etc/profile 重启source文件 8 java -version 若结果中出现下面信息则正确

Ubuntu 安装java环境搭建

1.下载JDK 8从http://www.oracle.com/technetwork/java/javasebusiness/downloads/选择下载JDK的最新版本 JDK 8. 2.解压文件$ sudo mkdir /usr/lib/jvm$ sudo mv jdk-8u11-linux-x64.tar.gz /usr/lib/jvm/ $ cd /usr/lib/jvm/$ sudo tar -zxvf jdk-8u11-linux-x64.tar.gz$ rm ./jdk-8u11

[转] Ubuntu/Linux Mint/Debian 安装 Java 8

本PPA由webupd8制作,支持Ubuntu 12.10, 12.04, 11.10, 11.04, 10.10 和 10.04以及对应的Linux Mint版本,Oracle Java 8包提供JDK8 和 JRE8. sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java8-installer 安装后查看版本: $ java -version java