工作中很多软件和工具需要依赖java环境,JDK作为java的开发环境,是经常需要安装的。
下载JDK二进制包
官方下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html 选择需要的jdk版本,下载就好,这里下载jdk-8u144-linux-x64.tar.gz
解压到指定目录
tar zxvf jdk-8u144-linux-x64.tar.gz -C /usr/local/ ln -s /usr/local/jdk-8u144-linux-x64 /usr/local/java
设置java环境变量
export JAVA_HOME=/usr/local/java export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$JAVA_HOME/bin:$PATH
验证
[root@mysql-amoeba ~]# source /etc/profile [root@mysql-amoeba ~]# java -version java version "1.8.0_144" Java(TM) SE Runtime Environment (build 1.8.0_144-b01) Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
tomcat 安装
tomcat下载链接https://mirrors.cnnic.cn/apache/tomcat/tomcat-8/v8.5.20/bin/apache-tomcat-8.5.20.tar.gz
解压安装
tar zxvf apache-tomcat-8.5.20.tar.gz -C /usr/local/ ln -sv /usr/local/apache-tomcat-8.5.20/ /usr/local/tomcat
基本命令
启动/usr/local/tomcat/bin/startup.sh或/usr/local/tomcat/bin/catalina.sh run
关闭/usr/local/tomcat/bin/shutdown.sh或/usr/local/tomcat/bin/catalina.sh stop