一:环境安装
操作系统:Ubuntu 18.04
JDK版本:JDK1.8
远程工具:SecureCRT 7.3
云盘地址:JDK1.8,SecureCRT 7.3,
官网下载的JDK请选择如下图版本:
二:JDK安装
1、使用CRT远程打开服务器
2、选择JDK要安装的目录,以/usr/local/为例
root@instance-8scsy8qh:~# cd /usr/local/ root@instance-8scsy8qh:/usr/local# mkdir java root@instance-8scsy8qh:/usr/local# root@instance-8scsy8qh:/usr/local# ls bin etc games include java lib man sbin share src
3、解压并把JDK版本放置到 /usr/local/java/ 下
root@instance-8scsy8qh:~/softwares# tar -zxvf jdk-8u191-linux-x64.tar.gz root@instance-8scsy8qh:~/softwares# ls jdk1.8.0_191 jdk-8u191-linux-x64.tar.gz root@instance-8scsy8qh:~/softwares# mv jdk1.8.0_191/ /usr/local/java/ root@instance-8scsy8qh:~/softwares# cd /usr/local/java/ root@instance-8scsy8qh:/usr/local/java# ls jdk1.8.0_191 root@instance-8scsy8qh:/usr/local/java#
说明:解压-移动到指定目录
三:JDK环境变量配置
这时候JDK就已经准备好了,但是环境我们并没有配置,所以还是Ubuntu系统目前是无法识别并找到该JDK的,验证如下:
root@instance-8scsy8qh:/usr/local/java# java -version Command 'java' not found, but can be installed with: apt install default-jre apt install openjdk-11-jre-headless apt install openjdk-8-jre-headless root@instance-8scsy8qh:/usr/local/java#
那么接下来就需要跟类似Windows环境下配置JDK一样了
这边以全局变量作为配置内容,即修改 /etc/profile
root@instance-8scsy8qh:/usr/local/java# vim /etc/profile # /etc/profile: system-wide .profile file for the Bourne shell (sh(1)) # and Bourne compatible shells (bash(1), ksh(1), ash(1), ...). if [ "${PS1-}" ]; then if [ "${BASH-}" ] && [ "$BASH" != "/bin/sh" ]; then # The file bash.bashrc already sets the default PS1. # PS1='h:w$ ' if [ -f /etc/bash.bashrc ]; then . /etc/bash.bashrc fi else if [ "`id -u`" -eq 0 ]; then PS1='# ' else PS1='$ ' fi fi fi if [ -d /etc/profile.d ]; then for i in /etc/profile.d/*.sh; do if [ -r $i ]; then . $i fi done unset i fi export JAVA_HOME=/usr/local/java/jdk1.8.0_191 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}
检查是否配置成功
root@instance-8scsy8qh:~# java -version java version "1.8.0_191" Java(TM) SE Runtime Environment (build 1.8.0_191-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode) root@instance-8scsy8qh:~#
到此,该系统中就已经安装好JDK环境了