LinuxCentos7下一键安装JDK

安装JDK

安装之前先检查一下系统有没有自带open-jdk

[root@39 ~]# rpm -qa |grep java
[root@39 ~]# rpm -qa |grep jdk
[root@39 ~]# rpm -qa |grep gcj

如果没有输入信息表示没有安装
如果有安装可以使用如下命令批量卸载所有带有Java的文件

[root@39 ~]# rpm -qa | grep java | xargs rpm -e --nodeps 
rpm: no packages given for erase

首先检索包含java的列表

[root@39 ~]yum list java*

检索1.8的列表

[root@39 ~]yum list java-1.8*   

安装1.8.0的所有文件

[root@39 ~]yum install java-1.8.0-openjdk* -y

使用命令检查是否安装成功

[root@39 ~]# 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)

注意:有的安装可能是1.8.0_151后面的配置JDK的需要自己做改动,因为安装目录的版本号也不一样的
Java1.8.0_151的安装目录是/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64
Java1.8.0_191的安装目录是/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64

配置JDK环境变量并生效

echo 'export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64' >> ~/.bashrc
echo 'export JRE_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64' >> ~/.bashrc
echo 'export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib' >> ~/.bashrc
echo 'export PATH=$PATH:$JAVA_HOME/bin' >> ~/.bashrc
exec $SHELL -l

151的

echo 'export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64' >> ~/.bashrc
echo 'export JRE_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.151-5.b12.el7_4.x86_64' >> ~/.bashrc
echo 'export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib' >> ~/.bashrc
echo 'export PATH=$PATH:$JAVA_HOME/bin' >> ~/.bashrc
exec $SHELL -l

242版本的

echo 'export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el8_1.x86_64' >> ~/.bashrc
echo 'export JRE_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.el8_1.x86_64' >> ~/.bashrc
echo 'export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib' >> ~/.bashrc
echo 'export PATH=$PATH:$JAVA_HOME/bin' >> ~/.bashrc
exec $SHELL -l

252版本的

echo 'export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64' >> ~/.bashrc
echo 'export JRE_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el7_8.x86_64' >> ~/.bashrc
echo 'export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib' >> ~/.bashrc
echo 'export PATH=$PATH:$JAVA_HOME/bin' >> ~/.bashrc
exec $SHELL -l

安装Crypto

pip install crypto

你可能感兴趣的:(LinuxCentos7下一键安装JDK)