下载地址: Java Downloads | Oracle
# 创建目录
mkdir /usr/local/java
# 解压文件到指定目录
tar -zxvf ./jdk-11.0.15.1_linux-x64_bin.tar.gz -C /usr/local/java
# 打开配置文件
vi /etc/profile
# 在文件末尾添加
export JAVA_HOME=/usr/local/java/jdk-11.0.15.1
export PATH=$JAVA_HOME/bin:$PATH
# 刷新环境变量
source /etc/profile
java -version
备注:
1. 创建软链接
# 创建软链接
ln -s /usr/local/java/jdk-11.0.15.1/bin/java /usr/bin
2. No appropriate protocol (protocol is disabled or cipher suites are inappropriate)
javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate
修改文件/usr/local/java/jdk-11.0.15.1/conf/security/java.security, 重启项目
# 原内容
jdk.tls.disabledAlgorithms=SSLv3, TLSv1, TLSv1.1, RC4, DES, MD5withRSA, \
DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, \
include jdk.disabled.namedCurves
# 修改后, 去掉SSLv3, TLSv1, TLSv1.1,
jdk.tls.disabledAlgorithms=RC4, DES, MD5withRSA, \
DH keySize < 1024, EC keySize < 224, 3DES_EDE_CBC, anon, NULL, \
include jdk.disabled.namedCurves
3.-bash: /usr/local/java/jdk-11.0.15.1/bin/java: cannot execute binary file: Exec format error
# 命令
uname -a
# 返回结果
5.10.112-11.al8.aarch64 #1 SMP Tue May 24 15:43:21 CST 2022 aarch64 aarch64 aarch64 GNU/Linux
如果有aarch64,需要更换安装包jdk-11.0.15.1_linux-aarch64_bin.tar.gz