概述
1、安装jdk
(1)jdk下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
根据自己系统需求进行下载,我下载的为64位,linux:jdk-8u131-linux-x64.tar.gz
(2)将压缩包放入/usr/lib/jvm下进行解压
#tar zvxf ./jdk-8u131-linux-x64.tar.gz
(3)添加环境变量
#vim ~/.bashrc
在文件最后加入如下内容,然后保存退出
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
#source .bashrc
(4)验证安装成功
#java -version
输出如下结果:
openjdk version "1.8.0_111"
OpenJDK Runtime Environment (build 1.8.0_111-8u131-b14-2ubuntu0.16.04.2-b14)
OpenJDK 64-Bit Server VM (build 25.111-b14, mixed mode)
2、安装tomcat
(1)下载tomcat7地址:http://tomcat.apache.org,应该从“Binary Distributions“的下载core包
安装包名称为:apache-tomcat-7.0.78.tar.gz
(2)解压,文件添加执行权限
将压缩包放到/opt/tomcat中
#cd /opt/tomcat
#tar zvxf ./apache-tomcat-7.0.78.tar.gz
#cd bin
#chmod +x *.sh
(3)配置环境变量
#vim /etc/profile
加入如下内容后保存退出:
#export CLASSPATH=$CLASSPATH:%JAVA_HOME/lib/tools.jar
#export TOMCAT_HOME=/opt/tomcat/apache-tomcat-7.0.78
#export CATALINA_HOME=$TOMCAT_HOME
#export PATH=$PATH:$TOMCAT_HOM/bin
进入apache-tomcat-7.0.78/bin文件中
#vim ./catalina.sh
在cygwin=false一行的上面,加入JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64,即jdk的路径
(4)打开和关闭tomcat
进入apache-tomcat-7.0.78/bin文件中
#./startup.sh
输出内容为:
Using CATALINA_BASE: /opt/tomcat/apache-tomcat-7.0.78
Using CATALINA_HOME: /opt/tomcat/apache-tomcat-7.0.78
Using CATALINA_TMPDIR: /opt/tomcat/apache-tomcat-7.0.78/temp
Using JRE_HOME: /usr/lib/jvm/java-8-openjdk-amd64/jre
Using CLASSPATH: /opt/tomcat/apache-tomcat-7.0.78/bin/bootstrap.jar:/opt/tomcat/apache-tomcat-7.0.78/bin/tomcat-juli.jar
Tomcat started.
#ps -ef| grep tomcat
输出内容为:
root 2075 1 43 11:30 pts/2 00:00:02 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java -Djava.util.logging.config.file=/opt/tomcat/apache-tomcat-7.0.78/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.endorsed.dirs=/opt/tomcat/apache-tomcat-7.0.78/endorsed -classpath /opt/tomcat/apache-tomcat-7.0.78/bin/bootstrap.jar:/opt/tomcat/apache-tomcat-7.0.78/bin/tomcat-juli.jar -Dcatalina.base=/opt/tomcat/apache-tomcat-7.0.78 -Dcatalina.home=/opt/tomcat/apache-tomcat-7.0.78 -Djava.io.tmpdir=/opt/tomcat/apache-tomcat-7.0.78/temp org.apache.catalina.startup.Bootstrap start
root 2124 440 0 11:30 pts/2 00:00:00 grep --color=auto tomcat
#./shutdown.sh
Using CATALINA_BASE: /opt/tomcat/apache-tomcat-7.0.78
Using CATALINA_HOME: /opt/tomcat/apache-tomcat-7.0.78
Using CATALINA_TMPDIR: /opt/tomcat/apache-tomcat-7.0.78/temp
Using JRE_HOME: /usr/lib/jvm/java-8-openjdk-amd64/jre
Using CLASSPATH: /opt/tomcat/apache-tomcat-7.0.78/bin/bootstrap.jar:/opt/tomcat/apache-tomcat-7.0.78/bin/tomcat-juli.jar
最后
以上就是动人大叔为你收集整理的ubuntu下安装jdk和tomcat的全部内容,希望文章能够帮你解决ubuntu下安装jdk和tomcat所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复