• LINUX 常用操作指令---安装与配置JDK环境


    一:环境安装

    操作系统:Ubuntu 18.04 

    JDK版本:JDK1.8

    远程工具:SecureCRT 7.3

     云盘地址:JDK1.8SecureCRT 7.3

    官网下载的JDK请选择如下图版本:

     二:JDK安装

    1、使用CRT远程打开服务器

     2、选择JDK要安装的目录,以/usr/local/为例

    root@instance-8scsy8qh:~# cd /usr/local/
    root@instance-8scsy8qh:/usr/local# mkdir java
    root@instance-8scsy8qh:/usr/local# 
    root@instance-8scsy8qh:/usr/local# ls
    bin  etc  games  include  java  lib  man  sbin  share  src

    3、解压并把JDK版本放置到 /usr/local/java/ 下

    root@instance-8scsy8qh:~/softwares# tar -zxvf jdk-8u191-linux-x64.tar.gz 
    root@instance-8scsy8qh:~/softwares# ls
    jdk1.8.0_191  jdk-8u191-linux-x64.tar.gz
    root@instance-8scsy8qh:~/softwares# mv jdk1.8.0_191/ /usr/local/java/
    root@instance-8scsy8qh:~/softwares# cd /usr/local/java/
    root@instance-8scsy8qh:/usr/local/java# ls
    jdk1.8.0_191
    root@instance-8scsy8qh:/usr/local/java#

    说明:解压-移动到指定目录

    三:JDK环境变量配置

    这时候JDK就已经准备好了,但是环境我们并没有配置,所以还是Ubuntu系统目前是无法识别并找到该JDK的,验证如下:

    root@instance-8scsy8qh:/usr/local/java# java -version
    
    Command 'java' not found, but can be installed with:
    
    apt install default-jre            
    apt install openjdk-11-jre-headless
    apt install openjdk-8-jre-headless 
    
    root@instance-8scsy8qh:/usr/local/java# 

    那么接下来就需要跟类似Windows环境下配置JDK一样了

    这边以全局变量作为配置内容,即修改 /etc/profile 

    root@instance-8scsy8qh:/usr/local/java# vim /etc/profile
    # /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
    # and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
    
    if [ "${PS1-}" ]; then
      if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then
        # The file bash.bashrc already sets the default PS1.
        # PS1='h:w$ '
        if [ -f /etc/bash.bashrc ]; then
          . /etc/bash.bashrc
        fi
      else
        if [ "`id -u`" -eq 0 ]; then
          PS1='# '
        else
          PS1='$ '
        fi
      fi
    fi
    
    if [ -d /etc/profile.d ]; then
      for i in /etc/profile.d/*.sh; do
        if [ -r $i ]; then
          . $i
        fi
      done
      unset i
    fi
    
    export JAVA_HOME=/usr/local/java/jdk1.8.0_191
    export JRE_HOME=${JAVA_HOME}/jre
    export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
    export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
    export PATH=$PATH:${JAVA_PATH}

     检查是否配置成功

    root@instance-8scsy8qh:~# java -version
    java version "1.8.0_191"
    Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
    Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
    root@instance-8scsy8qh:~# 

    到此,该系统中就已经安装好JDK环境了

  • 相关阅读:
    【推荐】 HyperLedger Fabric环境搭建、测试及注意事项 [详尽指导] [亲测有效]
    Ubuntu16.04 部署安装Docker容器 & 注意事项
    Ubuntu16.04 部署配置GO语言开发环境 & 注意事项
    ubuntu文件系统分区调整(解决目录空间不足、分配不均问题)
    区块链技术开发路线
    区块链技术现状&前景
    [兴业银行研究报告] 区块链与数字货币的发展现状、相互关联性及未来应用前景
    区块链技术的典型应用
    (转)akka Router实例
    org.springframework.beans.NotWritablePropertyException
  • 原文地址:https://www.cnblogs.com/dfsu/p/11915523.html
Copyright © 2020-2023  润新知