1. 使用yum查找jdk: yum search java|grep jdk

    # yum search java|grep jdk
    ldapjdk-javadoc.noarch : Javadoc for ldapjdk
    java-1.6.-openjdk.x86_64 : OpenJDK Runtime Environment
    java-1.6.-openjdk-demo.x86_64 : OpenJDK Demos
    java-1.6.-openjdk-devel.x86_64 : OpenJDK Development Environment
    java-1.6.-openjdk-javadoc.x86_64 : OpenJDK API Documentation
    java-1.6.-openjdk-src.x86_64 : OpenJDK Source Bundle
    java-1.7.-openjdk.x86_64 : OpenJDK Runtime Environment
    java-1.7.-openjdk-accessibility.x86_64 : OpenJDK accessibility connector
    java-1.7.-openjdk-demo.x86_64 : OpenJDK Demos
    java-1.7.-openjdk-devel.x86_64 : OpenJDK Development Environment
    java-1.7.-openjdk-headless.x86_64 : The OpenJDK runtime environment without
    java-1.7.-openjdk-javadoc.noarch : OpenJDK API Documentation
    java-1.7.-openjdk-src.x86_64 : OpenJDK Source Bundle
    java-1.8.-openjdk.i686 : OpenJDK Runtime Environment
    java-1.8.-openjdk.x86_64 : OpenJDK Runtime Environment
    java-1.8.-openjdk-accessibility.i686 : OpenJDK accessibility connector
    java-1.8.-openjdk-accessibility.x86_64 : OpenJDK accessibility connector
    java-1.8.-openjdk-accessibility-debug.i686 : OpenJDK accessibility connector
    java-1.8.-openjdk-accessibility-debug.x86_64 : OpenJDK accessibility connector
    java-1.8.-openjdk-debug.i686 : OpenJDK Runtime Environment with full debug on
    java-1.8.-openjdk-debug.x86_64 : OpenJDK Runtime Environment with full debug on
    java-1.8.-openjdk-demo.i686 : OpenJDK Demos
    java-1.8.-openjdk-demo.x86_64 : OpenJDK Demos
    java-1.8.-openjdk-demo-debug.i686 : OpenJDK Demos with full debug on
    java-1.8.-openjdk-demo-debug.x86_64 : OpenJDK Demos with full debug on
    java-1.8.-openjdk-devel.i686 : OpenJDK Development Environment
    java-1.8.-openjdk-devel.x86_64 : OpenJDK Development Environment
    java-1.8.-openjdk-devel-debug.i686 : OpenJDK Development Environment with full
    java-1.8.-openjdk-devel-debug.x86_64 : OpenJDK Development Environment with
    java-1.8.-openjdk-headless.i686 : OpenJDK Runtime Environment
    java-1.8.-openjdk-headless.x86_64 : OpenJDK Runtime Environment
    java-1.8.-openjdk-headless-debug.i686 : OpenJDK Runtime Environment with full
    java-1.8.-openjdk-headless-debug.x86_64 : OpenJDK Runtime Environment with full
    java-1.8.-openjdk-javadoc.noarch : OpenJDK API Documentation
    java-1.8.-openjdk-javadoc-debug.noarch : OpenJDK API Documentation for packages
    java-1.8.-openjdk-javadoc-zip.noarch : OpenJDK API Documentation compressed in
    java-1.8.-openjdk-javadoc-zip-debug.noarch : OpenJDK API Documentation
    java-1.8.-openjdk-src.i686 : OpenJDK Source Bundle
    java-1.8.-openjdk-src.x86_64 : OpenJDK Source Bundle
    java-1.8.-openjdk-src-debug.i686 : OpenJDK Source Bundle for packages with
    java-1.8.-openjdk-src-debug.x86_64 : OpenJDK Source Bundle for packages with
    java--openjdk.i686 : OpenJDK Runtime Environment
    java--openjdk.x86_64 : OpenJDK Runtime Environment
    java--openjdk-debug.i686 : OpenJDK Runtime Environment with full debug on
    java--openjdk-debug.x86_64 : OpenJDK Runtime Environment with full debug on
    java--openjdk-demo.i686 : OpenJDK Demos
    java--openjdk-demo.x86_64 : OpenJDK Demos
    java--openjdk-demo-debug.i686 : OpenJDK Demos with full debug on
    java--openjdk-demo-debug.x86_64 : OpenJDK Demos with full debug on
    java--openjdk-devel.i686 : OpenJDK Development Environment
    java--openjdk-devel.x86_64 : OpenJDK Development Environment
    java--openjdk-devel-debug.i686 : OpenJDK Development Environment with full
    java--openjdk-devel-debug.x86_64 : OpenJDK Development Environment with
    java--openjdk-headless.i686 : OpenJDK Headless Runtime Environment
    java--openjdk-headless.x86_64 : OpenJDK Headless Runtime Environment
    java--openjdk-headless-debug.i686 : OpenJDK Runtime Environment with full
    java--openjdk-headless-debug.x86_64 : OpenJDK Runtime Environment with full
    java--openjdk-javadoc.i686 : OpenJDK API documentation
    java--openjdk-javadoc.x86_64 : OpenJDK API documentation
    java--openjdk-javadoc-debug.i686 : OpenJDK API documentation for packages
    java--openjdk-javadoc-debug.x86_64 : OpenJDK API documentation for packages
    java--openjdk-javadoc-zip.i686 : OpenJDK API documentation compressed in
    java--openjdk-javadoc-zip.x86_64 : OpenJDK API documentation compressed in
    java--openjdk-javadoc-zip-debug.i686 : OpenJDK API documentation compressed
    java--openjdk-javadoc-zip-debug.x86_64 : OpenJDK API documentation
    java--openjdk-jmods.i686 : JMods for OpenJDK
    java--openjdk-jmods.x86_64 : JMods for OpenJDK
    java--openjdk-jmods-debug.i686 : JMods for OpenJDK with full debug on
    java--openjdk-jmods-debug.x86_64 : JMods for OpenJDK with full debug on
    java--openjdk-src.i686 : OpenJDK Source Bundle
    java--openjdk-src.x86_64 : OpenJDK Source Bundle
    java--openjdk-src-debug.i686 : OpenJDK Source Bundle for packages with debug
    java--openjdk-src-debug.x86_64 : OpenJDK Source Bundle for packages with
    ldapjdk.noarch : The Mozilla LDAP Java SDK
  2. 执行安装命令:yum install java-1.8.0-openjdk

    安装成功后,默认安装路径在/usr/lib/jvm/下边,
    如/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.144-0.b01.el6_9.x86_64

    查看安装路径(如下所示):
    which java
    ls -lrt /usr/bin/java

    [root@preproduct1 ~]# which java
    /usr/bin/java
    [root@preproduct1 ~]# echo $JAVA_HOME
    /usr/lib/jvm/java-1.8.-openjdk-1.8.0.191.b12-.el7_6.x86_64
    [root@preproduct1 ~]# ls -lrt /usr/bin/java
    lrwxrwxrwx root root Feb : /usr/bin/java -> /etc/alternatives/java
    [root@preproduct1 ~]# ls -lrt /etc/alternatives/java
    lrwxrwxrwx root root Feb : /etc/alternatives/java -> /usr/lib/jvm/java-1.8.-openjdk-1.8.0.191.b12-.el7_6.x86_64/jre/bin/java
    [root@preproduct1 ~]# cd /usr/lib/jvm
    [root@preproduct1 /usr/lib/jvm]# ll
    total
    lrwxrwxrwx root root Feb : java -> /etc/alternatives/java_sdk
    lrwxrwxrwx root root Feb : java-1.8. -> /etc/alternatives/java_sdk_1.8.0
    lrwxrwxrwx root root Feb : java-1.8.-openjdk -> /etc/alternatives/java_sdk_1..0_openjdk
    drwxr-xr-x root root Feb : java-1.8.-openjdk-1.8.0.191.b12-.el7_6.x86_64
    lrwxrwxrwx root root Feb : java-openjdk -> /etc/alternatives/java_sdk_openjdk
    lrwxrwxrwx root root Feb : jre -> /etc/alternatives/jre
    lrwxrwxrwx root root Feb : jre-1.8. -> /etc/alternatives/jre_1.8.0
    lrwxrwxrwx root root Feb : jre-1.8.-openjdk -> /etc/alternatives/jre_1..0_openjdk
    lrwxrwxrwx root root Feb : jre-1.8.-openjdk-1.8.0.191.b12-.el7_6.x86_64 -> java-1.8.-openjdk-1.8.0.191.b12-.el7_6.x86_64/jre
    lrwxrwxrwx root root Feb : jre-openjdk -> /etc/alternatives/jre_openjdk
  3. 验证java是否安装成功

    • 查看java版本:java -version

      # java -version
      openjdk version "1.8.0_191"
      OpenJDK Runtime Environment (build 1.8.0_191-b12)
      OpenJDK -Bit Server VM (build 25.191-b12, mixed mode)
    • 查看java是否可用:javac

      # javac
      -bash: javac: command not found

      错误原因:默认安装完只有运行环境,java安装目录下只有jre文件夹

  4. 安装开发环境yum install java-1.8.0-openjdk-devel.x86_64
    安装完可看到java安装目录下出现bin、lib等文件夹:

    [root@preproduct1 /usr/lib/jvm/java-1.8.-openjdk-1.8.0.191.b12-.el7_6.x86_64]# l
    total
    drwxr-xr-x root root Feb : bin
    drwxr-xr-x root root Feb : include
    drwxr-xr-x root root Feb : jre
    drwxr-xr-x root root Feb : lib
    drwxr-xr-x root root Feb : tapset

    再次输入javac说明安装成功

    # javac
    Usage: javac <options> <source files>
    where possible options include:
    -g Generate all debugging info
    -g:none Generate no debugging info
    -g:{lines,vars,source} Generate only some debugging info
    -nowarn Generate no warnings
    -verbose Output messages about what the compiler is doing
    -deprecation Output source locations where deprecated APIs are use
    -classpath <path> Specify where to find user class files and annotationocessors
    -cp <path> Specify where to find user class files and annotationocessors
    -sourcepath <path> Specify where to find input source files
    -bootclasspath <path> Override location of bootstrap class files
    -extdirs <dirs> Override location of installed extensions
    -endorseddirs <dirs> Override location of endorsed standards path
    -proc:{none,only} Control whether annotation processing and/or compilat is done.
    -processor <class1>[,<class2>,<class3>...] Names of the annotation processors ton; bypasses default discovery process
    -processorpath <path> Specify where to find annotation processors
    -parameters Generate metadata for reflection on method parameters
    -d <directory> Specify where to place generated class files
    -s <directory> Specify where to place generated source files
    -h <directory> Specify where to place generated native header files
    -implicit:{none,class} Specify whether or not to generate class files for imcitly referenced files
    -encoding <encoding> Specify character encoding used by source files
    -source <release> Provide source compatibility with specified release
    -target <release> Generate class files for specific VM version
    -profile <profile> Check that API used is available in the specified proe
    -version Version information
    -help Print a synopsis of standard options
    -Akey[=value] Options to pass to annotation processors
    -X Print a synopsis of nonstandard options
    -J<flag> Pass <flag> directly to the runtime system
    -Werror Terminate compilation if warnings occur
    @<filename> Read options and filenames from file
  5. 设置环境变量
    修改/etc/profile文件:vi /etc/profile
    在profile文件末尾新增如下内容:

    #set java environment
    JAVA_HOME=/usr/lib/jvm/java-1.8.-openjdk-1.8.0.191.b12-.el7_6.x86_64
    JRE_HOME=$JAVA_HOME/jre
    CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
    PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
    export JAVA_HOME JRE_HOME CLASS_PATH PATH

    使环境变量生效:source /etc/profile

    [root@preproduct1 /usr/lib/jvm]# cd /usr/lib/jvm
    [root@preproduct1 /usr/lib/jvm]# cd java-1.8.-openjdk-1.8.0.191.b12-.el7_6.x86_64/
    [root@preproduct1 /usr/lib/jvm/java-1.8.-openjdk-1.8.0.191.b12-.el7_6.x86_64]# source /etc/profile
    [root@preproduct1 /usr/lib/jvm/java-1.8.-openjdk-1.8.0.191.b12-.el7_6.x86_64]# echo $JAVA_HOME
    /usr/lib/jvm/java-1.8.-openjdk-1.8.0.191.b12-.el7_6.x86_64

至此jdk安装成功

linux 上使用yum 安装openjdk1.8的更多相关文章

  1. 转: Red Hat/Fedora Linux 上使用 yum 安装 python pip 模块

    from: http://www.cnblogs.com/moinmoin/archive/2012/03/07/red-hat-Fedora-python-pip-install-how.html ...

  2. 在linux上通过yum安装JDK

    完全转载自:https://my.oschina.net/andyfeng/blog/601291 这里完整粘贴一份留存 卸载centos自带的jdk 1.查看当前的jdk版本,并卸载 [root@l ...

  3. 学习 Mysql - 在linux上使用yum安装MySQL

    1.检查已经安装的mysql信息 yum list installed mysql*rpm -qa | grep mysql* 2.列出已安装和可安装的mysql信息 yum list mysql* ...

  4. 在CentOS linux上通过yum安装JDK<转>

    卸载centos自带的jdk 1.查看当前的jdk版本,并卸载 [root@localhost opt]#  rpm -qa|grep java  java-1.6.0-openjdk-1.6.0.3 ...

  5. 在linux上使用yum安装JDK

    1.查找java相关得列表 [qyf@localhost ~]$ yum -y list java* 执行结果 [qyf@localhost ~]$ yum -y list java* Loaded ...

  6. Linux上使用yum安装openjdk

    来源:https://www.cnblogs.com/yaun1498078591/p/10368884.html 使用yum查找jdk: yum search java|grep jdk # yum ...

  7. 【Oracle 集群】11G RAC 知识图文详细教程之RAC在LINUX上使用NFS安装前准备(六)

    RAC在LINUX上使用NFS安装前准备(六) 概述:写下本文档的初衷和动力,来源于上篇的<oracle基本操作手册>.oracle基本操作手册是作者研一假期对oracle基础知识学习的汇 ...

  8. 转载:【Oracle 集群】RAC知识图文详细教程(六)--RAC在LINUX上使用NFS安装前准备

    文章导航 集群概念介绍(一) ORACLE集群概念和原理(二) RAC 工作原理和相关组件(三) 缓存融合技术(四) RAC 特殊问题和实战经验(五) ORACLE 11 G版本2 RAC在LINUX ...

  9. CentOS上使用yum安装Apache

    关键词 CentOS上使用yum安装Apache 摘要 Apache在Linux系统中,其实叫“httpd”,它“无耻的”占据了官方名义!CentOS可以使用yum命令,非常简单和容易的安装Apach ...

随机推荐

  1. FullCalendar日历插件说明文档(看到这篇手册,解决了困扰我3天的js问题)

    FullCalendar提供了丰富的属性设置和方法调用,开发者可以根据FullCalendar提供的API快速完成一个日历日程的开发,本文将FullCalendar的常用属性和方法.回调函数等整理成中 ...

  2. sweetalert 弹框简单使用

    sweetalert网站 简单使用教程 拷贝文件 放到项目中 使用 页面效果 修改代码应用到事件中 成功删除演示(后台数据也会删除) 作 者:郭楷丰 出 处:https://www.cnblogs.c ...

  3. JDK8 stream用法

    forEach举例 public static void main(String[] args) { // TODO Auto-generated method stub List<Person ...

  4. Java集合学习(3):HashSet

    一.概述 HashSet实现Set接口,由哈希表(实际上是一个HashMap实例)支持.它不保证set 的迭代顺序:特别是它不保证该顺序恒久不变.此类允许使用null元素. HashSet是基于Has ...

  5. k8s 挂载卷介绍(四)

    kubernetes关于pod挂载卷的知识 首先要知道卷是pod资源的属性,pv,pvc是单独的资源.pod 资源的volumes属性有多种type,其中就包含有挂载pvc的类型.这也帮我理清了之间的 ...

  6. golang reflect知识集锦

    目录 反射之结构体tag Types vs Kinds reflect.Type vs reflect.Value 2019/4/20 补充 reflect.Value转原始类型 获取类型底层类型 遍 ...

  7. Django 之 restframework 解析器的使用

    请求头ContentType application/x-www-form-urlencoded 这应该是最常见的 POST 提交数据的方式了.浏览器的原生 <form> 表单,如果不设置 ...

  8. [Startup].Linux启动时间优化

    转自:https://www.cnblogs.com/agui125/p/10070559.html 正文 回到顶部 1. 实践过程 我是对海思3559进行启动时间优化的.具体的操作可以参考<H ...

  9. python中#!含义

    LINUX 上的 Shebang 符号(#!) #!这个符号叫做 Shebang 或者 Sha-bangShebang 通常在 Unix 系统脚本的中第一行开头使用指明执行这个脚本文件的解释程序 使用 ...

  10. MGR基本使用(转)

    第一章:MGR介绍 MGR(MySQL Group Replication)是一个MySQL Server插件,可用于创建弹性,高可用MySQL集群方案.有一个内置的组成员服务,在任何给定的时间点,保 ...