环境安装
jdk安装(rpm安装)
1、如果系统有自带openjdk 则需要卸载
1.1 查看系统是否自带JDK
在终端输入命令 java -version 结果如下
[root@suzhongde ~]# java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
1.2 查看相关java文件
在终端输入命令 rpm -qa | grep java
# 检查
[root@suzhongde ~]# rpm -qa|grep jdk
jdk1.8.0_121-1.8.0_121-fcs.x86_64
1.3 删除相关文件
# 卸载 -e --nodeps 强制删除
[root@suzhongde ~]# rpm -e --nodeps jdk1.8.0_121-1.8.0_121-fcs.x86_64
1.4 查看删除结果
在终端输入命令 java -version 出现以下结果表示删除成功
[root@suzhongde suzhongde]# java -version
-bash: /usr/bin/java: No such file or directory
2、tar下载地址OpenJDK JDK 18 Release-Candidate Builds
3、安装JDK
3.1 解压安装JDK
[root@suzhongde suzhongde]# tar -zxvf java1.8
4. 配置JDK环境变量
4.1 vim /etc/profile 在最后面添加如下配置
JAVA_HOME=/usr/java/jdk1.8.0_221-amd64
CLASSPATH=%JAVA_HOME%/lib:%JAVA_HOME%/jre/lib
PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
export PATH CLASSPATH JAVA_HOME
4.2 让新增的环境变量生效:在终端输入source /etc/profile
4.3 在终端输入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,
because you are running on a server-class machine.
-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.