Linux环境安装JDK:
一. 先创建文件夹: mkdir java
cd java
二.下载JDK并解压:
1, 手动下载并上传至Linux服务器
下载地址Oracle官网:
https://download.oracle.com/otn/java/jdk/8u231-b11
2, curl命令,亲测有效:
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”
解压: tar -zxvf jdk-8u141-linux-x64.tar.gz
三.设置环境变量
[root@localhost java]# vi /etc/profile
添加如下内容:
#set java environment
JAVA_HOME=/usr/java/jdk1.7.0_79
JRE_HOME=/usr/java/jdk1.7.0_79/jre
CLASS_PATH=.:
JAVA_HOME/lib/tools.jar:
PATH:
JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
让修改生效:
[root@localhost java]# source /etc/profile
4.验证
[root@localhost java]# java -version
java version “1.7.0_79”
Java? SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot? 64-Bit Server VM (build 24.79-b02, mixed mode)
或者使用export方式配置环境变量:
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk
export PATH=$PATH:/usr/lib/jvm/java-8-openjdk/bin
然后javac -version就可以看是否配置成功了.