将JDK的安装包上传到Linux系统的usr/local目录
使用xftp上传文件
解压JDK的压缩包
xshell连接到云主机
[root@theo ~]# cd /usr/local
[root@theo local]# ls
aegis apache-tomcat-8.5.46.tar.gz bin etc games include jdk-8u221-linux-x64.tar.gz lib lib64 libexec sbin share src
[root@theo local]# tar -zxvf jdk-8u221-linux-x64.tar.gz
查看解压后的目录结构
[root@theo local]# ls
aegis apache-tomcat-8.5.46.tar.gz bin etc games include jdk1.8.0_221 jdk-8u221-linux-x64.tar.gz lib lib64 libexec sbin share src
[root@theo local]# cd jdk1.8.0_221/
[root@theo jdk1.8.0_221]# ls
bin COPYRIGHT include javafx-src.zip jre lib LICENSE man README.html release src.zip THIRDPARTYLICENSEREADME-JAVAFX.txt THIRDPARTYLICENSEREADME.txt
[root@theo jdk1.8.0_221]# cd bin
[root@theo bin]# ls
appletviewer jar javadoc javapackager jconsole jhat jmc jsadebugd jvisualvm pack200 rmiregistry tnameserv xjc
ControlPanel jarsigner javafxpackager java-rmi.cgi jcontrol jinfo jmc.ini jstack keytool policytool schemagen unpack200
extcheck java javah javaws jdb jjs jps jstat native2ascii rmic serialver wsgen
idlj javac javap jcmd jdeps jmap jrunscript jstatd orbd rmid servertool wsimport
配置jdk环境
进入到/etc目录,找到profile文件
[root@theo bin]# cd /etc
[root@theo etc]# ls
编辑这个profile文件,在文件中添加JDK环境变量
vim profile
[root@theo etc]# vim profile 可以打开文件编辑器,必须输入字母i进入到编辑状态,在最后面添加如下四项配置
export JAVA_HOME=/usr/local/jdk1.8.0_221
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$JAVA_HOME/bin:$PATH
编辑完成之后,点击键盘“Esc”按键退出编辑状态,输入
:wq
保存并退出编辑器
重新加载配置文件查看java版本
[root@theo etc]# source /etc/profile
[root@theo etc]# java -version
java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)