前言

JDK是 JAVA 的软件开发工具包,如果要使用JAVA来进行开发,或者部署基于其开发的应用,那么就需要安装JDK。本次将在Linux下安装JDK及配置环境。

本人环境:CentOS 7.3 64位

下载JDK

在安装之前,检查是否存在Linux下自带的OpenJDK,命令:rpm -qa | grep java。若存在,则需要进行卸载,命令:rpm -e --nodeps 卸载的软件名

JDK历史版本链接:https://www.oracle.com/technetwork/java/javase/archive-139210.html

接着,我们可以通过 wget 命令下载JDK安装包,或者下载后传到Linux。我这里下载的安装包版本是 jdk-8u131-linux-x64.tar.gz

解压安装包

创建一个文件夹,用于存放JDK安装包,然后解压到该目录下。

创建文件夹:mkdir /root/JDK

进入文件夹:cd /root/JDK

解压:tar -zxvf /root/JDK/jdk-8u131-linux-x64.tar.gz

可以看到,本次解压到了当前目录 /root/JDK/jdk1.8.0_131下。

配置环境

解压完成之后,我们要配置下环境变量,通过 vim 命令修改配置文件 /etc/profile 来设置环境变量。

vim /etc/profile

在文件最后一行,输入 i 进入编辑模式,添加以下内容,然后按 Esc 退出编辑模式,再输入 :wq 保存并退出。

export JAVA_HOME=/root/JDK/jdk1.8.0_131
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

设置完之后,如果要使环境变量立即生效,需要通过命令:source /etc/profile,重新加载配置文件。

验证是否安装成功

所有都配置好了,我们需要验证下是否安装成功。

依次输入 java -versionjavajavac,不会出现报错并且显示出 jdk版本号java/javac相关命令参数说明界面

[root@wintest JDK]# java -version
-bash: java: command not found
[root@wintest JDK]# source /etc/profile
[root@wintest JDK]# java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
[root@wintest JDK]# java
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-server to select the "server" VM
The default VM is server. -cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A : separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose:[class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
Warning: this feature is deprecated and will be removed
in a future release.
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
Warning: this feature is deprecated and will be removed
in a future release.
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions with specified granularity
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
[root@wintest JDK]# 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@wintest JDK]#

Linux下安装JDK 1.8的更多相关文章

  1. Linux 下安装 jdk压缩包

    按 esc  退出  记得 输入 :q    记得 : Linux下安装jdk 把压缩文件放在 桌面的soft 下 在usr目录下新建文件夹Java,把文件复制到 usr/java 更改下路径! 3 ...

  2. linux 下安装jdk及配置jdk环境图解

    linux 下安装jdk及配置jdk环境图解 一:先检測是否已安装了JDK 运行命令: # rpm -qa|grep jdk  或   # rpm -q jdk  或  #find / -name j ...

  3. Linux 下 安装jdk 1.7

    Linux 下 安装jdk 1.7 参考百度经验 http://jingyan.baidu.com/album/ce09321b7c111f2bff858fea.html?picindex=6 第一步 ...

  4. Linux下安装JDK,Tomcat,Mysql详细教程

    1. 概述 今天教大家在linux下安装jdk,mysql以及tomcat.在javaweb开发中,最后完成的项目代码,一般都是布在linux服务器下的.因为linux服务器可以说是安全性稳定性都比w ...

  5. Linux下安装jdk&Jmeter

    一.在Linux上部署一个jdk以及Jmeter   tips1:Linux安装tar.gz文件到路径 tar -zxvf 软件包名.tar.gz -C 路径 比如我的jdk-8u131-linux- ...

  6. linux下安装jdk跟tomcat

    文章参考    https://www.cnblogs.com/geekdc/p/5607100.html   Linux服务器安装jdk+tomcat https://baijiahao.baidu ...

  7. Linux下安装JDK(小白教程)

    一.      选择与下载jdk 1. 官网上按照自己的系统版本下载相应jdk,因为我的LINUX(testbest)是32位的,所以我下载32位的jdk. 2. 官网下载地址:http://www. ...

  8. Linux下安装JDK 1.8你必须知道的糟心事

    来源:Atstudy网校 1.简介 在Oracle收购Sun后,Java的一系列产品就被整合到Oracle官网中,打开官网乍眼一看也不知道去哪里下载,还的一个一个的摸索尝试,而且网上大多数都是一些Or ...

  9. 1、Linux下安装JDK

    1.Linux下安装JDK 1 权限设置(可忽略) 1.1 安装过程与Windows安装过程相差不多,下载解压安装 1.切换root用户( 如果当前登录的用户权限够的话,请忽略这步) 由于创建目录的位 ...

随机推荐

  1. H3C 端口绑定典型配置举例

  2. codeforces 1183H 动态规划

    codeforces 1183H 动态规划 传送门:https://codeforces.com/contest/1183/problem/H 题意: 给你一串长度为n的字符串,你需要寻找出他的最长的 ...

  3. apk混淆打包和反编译(转)

    前面有人写过了,我就直接引用了,大家就不乱找了.以后有问题再继续更新. 一.混淆打包.编译 1.Android 代码混淆.http://blog.csdn.net/zjclugger/article/ ...

  4. 超简单!pytorch入门教程(四):准备图片数据集

    在训练神经网络之前,我们必须有数据,作为资深伸手党,必须知道以下几个数据提供源: 一.CIFAR-10 CIFAR-10图片样本截图 CIFAR-10是多伦多大学提供的图片数据库,图片分辨率压缩至32 ...

  5. Java核心技术·卷 II(原书第10版)分享下载

    Java核心技术·卷 II 内容介绍 Java领域最有影响力和价值的著作之一,由拥有20多年教学与研究经验的资深Java技术专家撰写(获Jolt大奖),与<Java编程思想>齐名,10余年 ...

  6. spring注解之@Import注解的三种使用方式

    目录 1.@Import注解须知 2.@Import的三种用法 3.@Import注解的三种使用方式总结 @ 1.@Import注解须知 1.@Import只能用在类上 ,@Import通过快速导入的 ...

  7. $NIM$游戏小总结

    $umm$可能之后会写个博弈论总结然后就直接把这个复制粘贴上去就把这个删了 但因为还没学完所以先随便写个$NIM$游戏总结趴$QAQ$ 首先最基础的$NIM$游戏:有$n$堆石子,每次可以从一堆中取若 ...

  8. 洛谷$P$4301 $[CQOI2013]$新$Nim$游戏 线性基+博弈论

    正解:线性基 解题报告: 传送门! 这题其实就是个博弈论+线性基,,,而且博弈论还是最最基础的那个结论,然后线性基也是最最基础的那个板子$QwQ$ 首先做这题的话需要一点点儿博弈论的小技能,,,这题的 ...

  9. linux dubbo-admin-2.6.0 环境搭建

    1.去maven官网下载apache-maven-3.6.2-bin.tar.gz安装包 2.上传至linux服务器中 3.解压maven安装包 tar -zxvf apache-maven-3.6. ...

  10. 【转】Matlab多项式拟合

    转:https://blog.csdn.net/hwecc/article/details/80308397 例: x = [0.33, 1.12, 1.41, 1.71, 2.19] y = [0. ...