1、下载JDK和Tomcat
//通过wget下载
wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.4/bin/apache-tomcat-8.5.4.tar.gz
wget http://download.oracle.com/otn-pub/java/jdk/8u131- b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz?AuthParam=1498630374_ed6e8b60e10c2fa6bd317a72378bf086
2、JDK安装与配置
a、JDK解压
mkdir /usr/local/javacd /usr/local/javatar -zxvf jdk-8u101-linux-x64.tar.gz
b、配置环境
export JAVA_HOME=/usr/local/java
export JAVA_BIN=$JAVA_HOME/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
c、使配置生效
source /etc/profile
d、测试java是否安装成功
java -version
//java版本信息java version"1.7.0_101"OpenJDK Runtime Environment (IcedTea2.6.6) (7u101-2.6.6-0ubuntu0.14.04.1)OpenJDK64-Bit Server VM (build24.95-b01, mixed mode)
第二种方法:只需要一条命令就可以安装jdk:
yum install java-1.8.0-openjdk* -y
执行了这条命令不需要配置,直接可以用
网友评论