1. install default JRE/JDK
    1. Installing Java with apt-get is easy. First, update the package index:

      • sudo apt-get update
    2. check if Java is not already installed:
      • java -version
    3. If it returns "The program java can be found in the following packages", Java hasn't been installed yet, so execute the following command:
      • sudo apt-get default-jre(This will install the Java Runtime Environment (JRE). )
    4. If you instead need the Java Development Kit (JDK), which is usually needed to compile Java applications (for example Apache Ant, Apache Maven, Eclipse and IntelliJ IDEA execute the following command:
      • sudo apt-get install default-jdk
    5. That is everything that is needed to install Java.All other steps are optional and must only be executed when needed.
  2. Installing Oracle JDK (optional)
    1. The Oracle JDK is the official JDK; however, it is no longer provided by Oracle as a default installation for Ubuntu.
    2. You can still install it using apt-get.
    3. To install any version, first execute the following commands:
      • sudo apt-get install python-software-properties
      • sudo add-apt-repository ppa:webupd8team/java
      • sudo apt-get update
    4. Then, depending on the version you want to install, execute one of the following commands:
      1. Oracle JDK6:This is an old version but still in use.

        • sudo apt-get install oracle-java6-installer
      2. Oracle JDK7:This is the latest stable version.
        • sudo apt-get install oracle-java7-installer
      3. Oracle JDK8:This is a developer preview, the general release is scheduled for March 2014. This external article about Java 8 may help you to understand what it's all about.
        • sudo apt-get install oracle-java8-installer
  3. Managing Java (optional)(多版本环境下设置默认使用的版本)
    1. When there are multiple Java installations on your Droplet, the Java version to use as default can be chosen. To do this, execute the following command:

      • sudo update-alternatives --config java
    2. It will usually return something like this if you have 2 installations (if you have more, it will of course return more):
    3. You can now choose the number to use as default. This can also be done for the Java compiler (javac):
      • sudo update-alternatives --config javac
    4. Setting the "JAVA_HOME" environment variable(取得Java安装路径,设置Java环境变量)
      1. To set the JAVA_HOME environment variable, which is needed for some programs, first find out the path of your Java installation:

        • sudo update-alternatives --config java
      2. It returns something like:
      3. The path of the installation is for each:
        •  /usr/lib/jvm/java-7-oracle
        • /usr/lib/jvm/java-6-openjdk-amd64
        • /usr/lib/jvm/java-7-oracle
      4. Copy the path from your preferred installation and then edit the file /etc/environment:
        • sudo nano /etc/environment
      5. In this file, add the following line (replacing YOUR_PATH by the just copied path):
        • JAVA_HOME="YOUR_PATH"
      6. That should be enough to set the environment variable. Now reload this file:
        • source /etc/environment
      7. Test it by executing:
        • echo $JAVA_HOME(If it returns the just set path, the environment variable has been set successfully. If it doesn't, please make sure you followed all steps correctly.
  4. 通过URL链接安装jdk1.8
    • wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-x64.tar.gz
      sudo mkdir /usr/java
      sudo tar zxf jdk-8u91-linux-x64.tar.gz -C /usr/java
      sudo echo "export JAVA_HOME=/usr/java/jdk1.8.0_91" >> /etc/bashrc
      sudo "export PATH=$PATH:$JAVA_HOME/bin" >> /etc/bashrc
      sudo echo "export CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar" >> /etc/bashrc
      source /etc/bashrc

(2)Linux Java环境变量安装的更多相关文章

  1. [知了堂学习笔记]_牵线Eclipse和Tomcat第一篇 —— 配置Java环境变量&&安装eclipse

    一.先给他们提供一个"浪漫的"环境,比如传说中的"鹊桥"--java环境变量.哈哈! 配置java环境变量. 下载jdk,根据自己电脑的版本和操作位数选择不同的 ...

  2. linux java环境变量设置

    下载JRE或者JDK后解压,设置以下环境变量 JAVA_HOME=/home/zm/jdk1.8.0_181JRE_HOME=/home/zm/jdk1.8.0_181/jreCLASSPATH=.: ...

  3. JAVA环境变量安装

    需配置的系统环境变量参数: JAVA_HOME:C:\Program Files\Java\jdk1.8.0_60 CLASS_PATH: ;%JAVA_HOME%\lib;%JAVA_HOME%\l ...

  4. Linux Java 环境变量设置

    对整个机器:所有用户 1,在/etc/profile 文件末尾加入 export JAVA_HOME=/var/opt/jdk1.7.0_04 export PATH=$JAVA_HOME/bin:$ ...

  5. Linux中如何设置java环境变量

    这里介绍Linux下如何设置java环境变量. 工具/原料 Linux java环境变量 方法/步骤 1 查看java的安装路径   查看java执行路径   配置java环境变量   java的安装 ...

  6. JDK的安装与配置java环境变量

    JDK安装与配置java环境变量 安装JDK 1.百度搜索jdk8找到下载地址 下载地址:Java SE Development Kit 8 - Downloads (oracle.com) 2.点击 ...

  7. linux配置java环境变量(详细)

    linux配置java环境变量(详细) 本文完全引用自: http://www.cnblogs.com/samcn/archive/2011/03/16/1986248.html 一. 解压安装jdk ...

  8. linux配置java环境变量

    linux配置java环境变量(详细) 一. 解压安装jdk 在shell终端下进入jdk-6u14-linux-i586.bin文件所在目录, 执行命令 ./jdk-6u14-linux-i586. ...

  9. 14行脚本配置Linux下一个Java环境变量

    供Java人们刚开始学习.多半Java它需要花费大量的精力在开发环境的配置,于Linux下一个,构造Java环境变量,很可能加入这一努力. 为此,我做了一个bash脚本来配置自己主动Java环境变量. ...

随机推荐

  1. setCascadeOpacityEnabled

    setCascadeOpacityEnabled Enable or disable cascade opacity, if cascade enabled, child nodes' opacity ...

  2. C++-hihoCode-1105/1109-[STL][堆][prime]

    #include <set> #include <map> #include <cmath> #include <queue> #include < ...

  3. index unique scan 与index range scan等的区别

    存取Oracle当中扫描数据的方法(一) Oracle 是一个面向Internet计算环境的数据库.它是在数据库领域一直处于领先地位的甲骨文公司的产品.可以说Oracle关系数据库系统是目前世界上流行 ...

  4. bzoj 4827: [HNOI2017]礼物 (FFT)

    一道FFT 然而据说暴力可以水70分 然而我省选的时候看到了直接吓傻了  连暴力都没打 太弱了啊QAQ emmmm 详细的拆开就看其他题解吧233 最后那一步卷积其实我一直没明白 后来画画图终于懂了 ...

  5. 【PAT甲级】1114 Family Property (25分)(并查集)

    题意: 输入一个正整数N(<=10000),接着输入N行每行包括一个人的ID和他双亲的ID以及他的孩子数量和孩子们的ID(四位整数包含前导零),还有他所拥有的房产数量和房产面积.输出一共有多少个 ...

  6. C语言合法标识符 题解

    输入一个字符串,判断其是否是C的合法标识符.  Input输入数据包含多个测试实例,数据的第一行是一个整数n,表示测试实例的个数,然后是n行输入数据,每行是一个长度不超过50的字符串. Output对 ...

  7. 神经网络的基础-Graph,Session

    张量:基于 Tensorflow 的 NN:用张量表示数据,用计算图搭建神经网络,用会话执行计算图,优化线上的权重(参数),得到模型. 张量:张量就是多维数组(列表),用“阶”表示张量的维度. 0 阶 ...

  8. Mac系统升级后git没法使用的问题

    今天更新了mac系统(Catalina)发现之前的项目没法提交,然后大概查了一下啊mac更新方面的问题 mac每次更新时系统就会卸载xcode 在终端输入  xcode-select --instal ...

  9. leetcode 25. K 个一组翻转链表

    # coding:utf-8 __author__ = "sn" """ 25. K 个一组翻转链表 给你一个链表,每 k 个节点一组进行翻转,请你返 ...

  10. Navicat Premium破解

    1.正常下载安装 2.把PatchNavicat.exe文件放到Navicat安装目录下 3.以管理员身份启动PatchNavicat.exe 4.运行Navicat即可