zoukankan      html  css  js  c++  java
  • (2)Linux Java环境变量安装

    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





  • 相关阅读:
    蚂蚁金服井贤栋:用技术联手金融机构,形成服务小微的生态合力
    蚂蚁金服 Service Mesh 渐进式迁移方案|Service Mesh Meetup 实录
    蚂蚁金服“定损宝”现身AI顶级会议NeurIPS
    报名 | 蚂蚁金服ATEC科技大会 · 上海:数字金融新原力
    前沿 | 中国中小银行都是如何展开数字化转型的?
    盘点:2018年双11背后的蚂蚁核心技术
    构筑敏捷能力中心,打造下一代数字银行“操作系统”!
    客户故事:4家银行如何打造新一代移动金融中心
    干货 | 金融级互联网产品持续交付的挑战与应对
    性能跃升50%!解密自主研发的金融级分布式关系数据库OceanBase 2.0
  • 原文地址:https://www.cnblogs.com/yangzsnews/p/7496694.html
Copyright © 2011-2022 走看看