zoukankan      html  css  js  c++  java
  • Linux-JDK安装

    1、下载

    去oracle官网下载jdk https://www.oracle.com/technetwork/cn/java/javase/downloads/jdk8-downloads-2133151-zhs.html

    我使用的是 jdk-8u201-linux-x64.tar.gz

    2、解压

    我解压到了/opt/software目录

    [root@localhost package]# tar -zxvf jdk-8u201-linux-x64.tar.gz -C /opt/software/
    

    3、配环境变量

    /etc/profile文件的改变会涉及到系统的环境,我们要将jdk配置到/etc/profile,才可以在任何一个目录访问jdk

    编辑文件

    [root@localhost jdk1.8.0_201]# vim /etc/profile
    

    按Shift+G到文件末尾,按o向下一行编辑,粘贴下面内容。

    export JAVA_HOME=/opt/software/jdk1.8.0_201  #jdk安装目录
    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}
    

    wq保存退出。

    编辑后生效

    [root@localhost jdk1.8.0_201]# source /etc/profile
    

    4、检测

    输入javac 或者 java -version

    [root@localhost jdk1.8.0_201]# 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 used
      -classpath <path>          Specify where to find user class files and annotation processors
      -cp <path>                 Specify where to find user class files and annotation processors
      -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 compilation is done.
      -processor <class1>[,<class2>,<class3>...] Names of the annotation processors to run; 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 implicitly 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 profile
      -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
    
    
    [root@localhost jdk1.8.0_201]# java -version
    java version "1.8.0_201"
    Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
    Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
    
    
  • 相关阅读:
    【车】平安车险费用
    【光环国际】掌握项目经理12个工作流程
    【光环国际】500强公司7个项目管理工具
    数据仓库和商业智能演进五个阶段
    【技术与商业案例解读笔记】095:Google大数据三驾马车笔记
    15道最常考的SpringBoot面试题,你都遇到过哪些?
    用户画像4:标签数据开发
    plsql 传参
    shell专题(二):Shell解析器
    shell专题(三):Shell脚本入门
  • 原文地址:https://www.cnblogs.com/AganRun/p/12080701.html
Copyright © 2011-2022 走看看