Centos7中yum安装jdk及配置环境变量
系统版本
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
#安装之前先查看一下有无系统自带jdk
rpm -qa |grep java rpm -qa |grep jdk rpm -qa |grep gcj
#如果有就使用批量卸载命令
rpm -qa | grep java | xargs rpm -e --nodeps
直接yum安装1.8.0版本openjdk
[root@localhost ~]# yum install java-1.8.0-openjdk* -y
查看版本
[root@localhost ~]# java -version
openjdk version "1.8.0_161"
OpenJDK Runtime Environment (build 1.8.0_161-b14)
OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)
默认jre jdk 安装路径是/usr/lib/jvm 下面
JAVA_HOME指向一个含有java可执行程序的目录(一般是在 bin/java中,此目录为/bin/java的上级目录),用cd 命令进入到 jvm下唯一的一个目录中 java-1.8.0-openjdk-1.8.0.161-0.b14.el7_3.x86_64,发现其下目录为
[root@localhost ~]# export JAVA_HOME=/usr/lib/jvm/<span style="font-family: Arial;">jre-1.8.0-openjdk-1.8.0.121-0.b13.el7_3.x86_64</span>
#当前用户生效的配置
vim ~/.bashrc
#在文件底部加入下面一句
export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64
#如果使所有用户生效的配置
vim /etc/profile
#set java environment
export JAVA_HOME=/usr/lib/jvm/java export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/lib/rt.jar export PATH=$PATH:$JAVA_HOME/bin
#使得配置生效
. /etc/profile
#查看变量
[root@localhost ~]# echo $JAVA_HOME
/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64
[root@localhost ~]# echo $CLASSPATH
.:/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/lib/dt.jar:/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.161-0.b14.el7_4.x86_64/lib/tools.jar
javac 和java 命令都有输出设置提示就表示安装和环境配置成功了
案例如下:
[root@instanc]# yum -y list java
Loaded plugins: langpacks, versionlock
Error: No matching Packages to list
[root@instanc]# rpm -qa |grep java
[root@instanc]# rpm -qa |grep jdk
[root@instanc]# rpm -qa |grep gcj
[root@instanc]# yum install java-1.8.0-openjdk* -y
--------中间有安装过程,最后complete
Complete!
[root@instance-ozyu8y37 ~]# java -version
openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)
[root@instance-ozyu8y37 ~]# cd /usr
[root@instance-ozyu8y37 usr]# ls
bin etc games include lib lib64 libexec local sbin share src tmp
[root@instance-ozyu8y37 usr]# cd lib
[root@instance-ozyu8y37 lib]# cd jvm
[root@instance-ozyu8y37 jvm]# ls
java
java-1.8.0
java-1.8.0-openjdk
java-1.8.0-openjdk-1.8.0.191.b12-0.el7_5.x86_64
java-1.8.0-openjdk-1.8.0.191.b12-0.el7_5.x86_64-debug
java-openjdk
jre
jre-1.8.0
jre-1.8.0-openjdk
jre-1.8.0-openjdk-1.8.0.191.b12-0.el7_5.x86_64
jre-1.8.0-openjdk-1.8.0.191.b12-0.el7_5.x86_64-debug
jre-openjdk
[root@instance-ozyu8y37 jvm]# vim /etc/profile # 配置java环境变量(所有用户)
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
pathmunge () {
case ":${PATH}:" in
*:"$1":*)
;;
*)
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
esac
}
if [ -x /usr/bin/id ]; then
if [ -z "$EUID" ]; then
# ksh workaround
EUID=`/usr/bin/id -u`
UID=`/usr/bin/id -ru`
fi
USER="`/usr/bin/id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
fi
#set java environment
export JAVA_HOME=/usr/lib/jvm/java
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/lib/rt.jar
export PATH=$PATH:$JAVA_HOME/bin
# Path manipulation
if [ "$EUID" = "0" ]; then
pathmunge /usr/sbin
pathmunge /usr/local/sbin
else
pathmunge /usr/local/sbin after
pathmunge /usr/sbin after
fi
HOSTNAME=`/usr/bin/hostname 2>/dev/null`
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
export HISTCONTROL=ignoreboth
else
export HISTCONTROL=ignoredups
fi
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
umask 002
else
umask 022
fi
for i in /etc/profile.d/*.sh /etc/profile.d/sh.local ; do
if [ -r "$i" ]; then
if [ "${-#*i}" != "$-" ]; then
. "$i"
else
. "$i" >/dev/null
fi
fi
done
unset i
unset -f pathmunge
setterm -blank 0 &> /dev/null
setterm -powersave off &> /dev/null
setterm -powerdown 0 &> /dev/null
ulimit -SHn 65535
[root@instance-ozyu8y37 jvm]# . /etc/profile #使配置生效
[root@instance-ozyu8y37 jvm]# 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@instance-ozyu8y37 jvm]# 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
至此jdk安装成功
Centos7中yum安装jdk及配置环境变量的更多相关文章
- LInux_CentosOS中yum安装jdk及配置环境变量
系统版本 [root@localhost ~]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core) #安装之前先查看一下有无系统 ...
- window 远程在Linux(centOS7.0)上安装JDK以及配置环境变量
本人是在windows 7 上安装了虚拟机,虚拟机安装的是linux(centOS7.0)系统现在在Windows 上安装SecureCRT 远程虚拟机的linux系统,安装JDK以及配置环境变量. ...
- Ubuntu安装JDK与配置环境变量
Ubuntu14.04安装JDK与配置环境变量 工具/原料 Ubuntu14.04系统 方法/步骤 先从Oracle官网下载JDK.先选择同意按钮,然后根据自己的系统下载相应版本.我的系统 ...
- 安装JDK并配置环境变量以及Hello World
摘要:本文主要说明在Windows环境下JDK的安装,以及安装完成之后环境变量的配置,并通过DOS运行简单的Java程序. 安装JDK 说明 SDK:软件开发工具包(Software Developm ...
- Linux环境下安装JDK并配置环境变量
首先查看是否已经安装了JDK并配置环境变量. [root@dhcc_plat opt]# java -version -bash: java: command not found [root@dhcc ...
- Java入门——在Linux环境下安装JDK并配置环境变量
Java入门——在Linux环境下安装JDK并配置环境变量 摘要:本文主要说明在Linux环境下JDK的安装,以及安装完成之后环境变量的配置. 使用已下载的压缩包进行安装 下载并解压 在Java的官网 ...
- 安装jdk并配置环境变量
安装jdk并配置环境变量 安装jdk 点击访问官网 https://www.oracle.com/downloads/或直接下载 https://www.jdkdownload.com/ 推荐使用后面 ...
- Linux安装JDK并配置环境变量
Linux - 安装jdk并配置环境变量 1. 前往JDK官网, 地址:https://www.oracle.com/java/technologies/downloads/ 复制下载链接 2. ...
- centos6.5下安装jdk并配置环境变量
链接: https://blog.csdn.net/wawawawawawaa/article/details/81158943 以下链接供参考: https://blog.csdn.net/Bugg ...
随机推荐
- 国产spfa瞎几把嗨
//在各种不利的因素下,我居然就这么水过了这题最短路,然而还wa了一次,因为路是双向的... //这题姿势很多啊,但自从会了国产spfa就是最短路能搞的就是spfa,优点太多了!!! //也是瞎几把打 ...
- WPF 加载 WINFORM控件 异常: 调度程序进程已挂起,但消息仍在处理中
在加载TradeAtServer的统计中的 单个合约盈亏情况 异常:,调度程序进程已挂起,但消息仍在处理中 发现可能是属性设置引发的问题 比如DateTimePikcer.Value+= set, g ...
- 洛谷 P4125 [WC2012]记忆中的水杉树【扫描线+set+线段树】
我没有找到能在bzojAC的代码--当然我也WA了--但是我在洛谷过了,那就假装过了吧 minmax线段树一开始写的只能用min更新min,max更新max,实际上是可以互相更新的-- 首先看第二问, ...
- 黑客攻防技术宝典web实战篇:攻击应用程序架构习题
猫宁!!! 参考链接:http://www.ituring.com.cn/book/885 随书答案. 1. 假设受攻击的应用程序使用两台不同的服务器:一台应用程序服务器和一台数据库服务器.已经发现一 ...
- Ubuntu18 安装jdk8
按照网上能找到的方法,添加仓库已经不行了,具体原因如下: I look up to the webupd8 site and it seems that the ppa was discontinue ...
- compose 函数实现
总结componse函数实现过程 大致特点 参数均为函数, 返回值也是函数 第一函数接受参数, 其他函数接受的上一个函数的返回值 第一个函数的参数是多元的, 其他函数的一元的 自右向左执行 简单实现 ...
- 507 Perfect Number 完美数
对于一个 正整数,如果它和除了它自身以外的所有正因子之和相等,我们称它为“完美数”.给定一个 正整数 n, 如果他是完美数,返回 True,否则返回 False示例:输入: 28输出: True解释: ...
- js 获取最后一个字符
方法一: str.charAt(str.length - 1) 方法二: str.subStr(str.length-1,1) 方法三: var str = "123456" ...
- [转]Android专家级别的面试总结
Android专家级别的面试总结 2017年02月15日 16:56:28 阅读数:1225 1.. 自定义View流程 onMeasure, onLayout, onDraw, 采用深度优先,因为必 ...
- LN : leetcode 416 Partition Equal Subset Sum
lc 416 Partition Equal Subset Sum 416 Partition Equal Subset Sum Given a non-empty array containing ...