Linux源码安装Java jdk环境

                                  Linux源码安装Java jdk环境

1.下载源码包

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.tar.gz"

2.解压下载包

mkdir  /usr/local/java
tar zxvf jdk-8u141-linux-x64.tar.gz  -C  /usr/local/java

3.配置环境变量

cat  /etc/profile 

JAVA_HOME=/usr/local/java/jdk1.8.0_141
JRE_HOME=/usr/local/java/jdk1.8.0_141/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH

4.使配置文件生效

source /etc/profile 

5.验证

[root@localhost ~]$ java -version
java version "1.8.0_141"
Java(TM) SE Runtime Environment (build 1.8.0_141-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.141-b15, mixed mode)

 如果没有Java命令,创建软连接:ln   -s   /usr/local/java/jdk1.8.0_141/bin/java    /usr/bin/java

 PS:卸载yum安装的jdk方法如下:

1.找出yum安装的java

yum list installed | grep java 

 2.java相关得列表

rpm  -e  --nodeps   java-1.8.0-openjdk.x86_64
rpm  -e  --nodeps   java-1.8.0-openjdk-devel.x86_64

PS:

How to Install Tomcat  on CentOS

https://tecadmin.net/install-tomcat-8-on-centos-rhel-and-ubuntu/

Tomcat下载地址:https://mirrors.cnnic.cn/apache/tomcat/

例如:

wget https://mirrors.cnnic.cn/apache/tomcat/tomcat-8/v8.5.42/bin/apache-tomcat-8.5.42.tar.gz

设置tomcat开机自启方法:

Linux源码安装Java jdk环境_第1张图片

你可能感兴趣的:(运维,Java)