Ubuntu16.04安装jdk,下载linux中的64版本

需要下载jdk,tomcat安装包 tar.gz版本的

http://pan.baidu.com/s/1mi4WVhA

安装JDK:

hongdada@ubuntu:~$ sudo mkdir /java
[sudo] hongdada 的密码:
hongdada@ubuntu:~$ cd /Downloads
bash: cd: /Downloads: 没有那个文件或目录
hongdada@ubuntu:~$ cd Downloads/
hongdada@ubuntu:~/Downloads$ sudo mv jdk-8u121-linux-x64.tar.gz /java
hongdada@ubuntu:~/Downloads$ sudo tar -zxvf jdk-8u121-linux-x64.tar.gz
tar (child): jdk-8u121-linux-x64.tar.gz:无法 open: 没有那个文件或目录
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
hongdada@ubuntu:~/Downloads$ cd java/
bash: cd: java/: 没有那个文件或目录
hongdada@ubuntu:~/Downloads$ cd ~
hongdada@ubuntu:~$ cd java/
bash: cd: java/: 没有那个文件或目录
hongdada@ubuntu:~$ cd /java
hongdada@ubuntu:/java$ sudo tar -zxvf jdk-8u121-linux-x64.tar.gz
jdk1.8.0_121/
jdk1.8.0_121/THIRDPARTYLICENSEREADME-JAVAFX.txt
jdk1.8.0_121/THIRDPARTYLICENSEREADME.txt
...............
jdk1.8.0_121/man/ja_JP.UTF-8/man1/jstat.1
hongdada@ubuntu:/java$ sudo gedit /etc/environment //修改/etc/environment中的内容 hongdada@ubuntu:~$ sudo gedit /etc/environment
[sudo] hongdada 的密码: (gedit:3856): IBUS-WARNING **: The owner of /home/hongdada/.config/ibus/bus is not root! (gedit:3856): Gtk-WARNING **: Calling Inhibit failed: GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.SessionManager was not provided by any .service files ** (gedit:3856): WARNING **: Set document metadata failed: 不支持设置属性 metadata::gedit-spell-enabled ** (gedit:3856): WARNING **: Set document metadata failed: 不支持设置属性 metadata::gedit-encoding ** (gedit:3856): WARNING **: Set document metadata failed: 不支持设置属性 metadata::gedit-spell-enabled ** (gedit:3856): WARNING **: Set document metadata failed: 不支持设置属性 metadata::gedit-encoding ** (gedit:3856): WARNING **: Set document metadata failed: 不支持设置属性 metadata::gedit-spell-enabled ** (gedit:3856): WARNING **: Set document metadata failed: 不支持设置属性 metadata::gedit-encoding ** (gedit:3856): WARNING **: Set document metadata failed: 不支持设置属性 metadata::gedit-position
hongdada@ubuntu:~$ source /etc/environment
hongdada@ubuntu:~$ java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

/etc/environment中文件修改为

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:$JAVA_HOME/bin"
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export JAVA_HOME=/java/jdk1.8.0_121

修改environment是修改系统的环境变量,还要修改登陆用户的环境变量,即修改/etc/profile的文件

hongdada@ubuntu:~$ sudo gedit /etc/profile

/etc/profile修改为:

 # /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...). if [ "$PS1" ]; then
if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
# The file bash.bashrc already sets the default PS1.
# PS1='\h:\w\$ '
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
else
if [ "`id -u`" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi #set java environment
export JAVA_HOME=/java/jdk1.8.0_121
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

使用命令使环境变量立即生效

source /etc/profile

重启电脑,能正常进入系统,且java -version命令有效

安装Tomcat9:

在java文件夹下面创建文件夹tomcat,迁移Downloads中的apache-tomcat-9.0.0.M17.tar.gz文件到tomcat文件夹中,解压

修改/java/tomcat/apache-tomcat-9.0.0.M17/bin/startup.sh文件

在文件底部添加

#set java environment
export JAVA_HOME=/java/jdk1.8.0_121
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH #tomcat
export TOMCAT_HOME=/java/tomcat/apache-tomcat-9.0.0.M17

添加之后的startup.sh文件

#!/bin/sh

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License. # -----------------------------------------------------------------------------
# Start Script for the CATALINA Server
# ----------------------------------------------------------------------------- # Better OS/400 detection: see Bugzilla 31132
os400=false
case "`uname`" in
OS400*) os400=true;;
esac # resolve links - $0 may be a softlink
PRG="$0" while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`/"$link"
fi
done PRGDIR=`dirname "$PRG"`
EXECUTABLE=catalina.sh # Check that target executable exists
if $os400; then
# -x will Only work on the os400 if the files are:
# 1. owned by the user
# 2. owned by the PRIMARY group of the user
# this will not work if the user belongs in secondary groups
eval
else
if [ ! -x "$PRGDIR"/"$EXECUTABLE" ]; then
echo "Cannot find $PRGDIR/$EXECUTABLE"
echo "The file is absent or does not have execute permission"
echo "This file is needed to run this program"
exit 1
fi
fi exec "$PRGDIR"/"$EXECUTABLE" start "$@" #set java environment
export JAVA_HOME=/java/jdk1.8.0_121
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH #tomcat
export TOMCAT_HOME=/java/tomcat/apache-tomcat-9.0.0.M17

启动Tomcat

hongdada@ubuntu:~$ cd /java
hongdada@ubuntu:/java$ cd tomcat
hongdada@ubuntu:/java/tomcat$ cd apache-tomcat-9.0.0.M17
hongdada@ubuntu:/java/tomcat/apache-tomcat-9.0.0.M17$ cd bin
bash: cd: bin: 权限不够
hongdada@ubuntu:/java/tomcat/apache-tomcat-9.0.0.M17$ sudo cd bin
sudo: cd:找不到命令
hongdada@ubuntu:/java/tomcat/apache-tomcat-9.0.0.M17$ sudo bin
sudo: bin:找不到命令
hongdada@ubuntu:/java/tomcat/apache-tomcat-9.0.0.M17$ sudo ./bin/startup.sh
Using CATALINA_BASE: /java/tomcat/apache-tomcat-9.0.0.M17
Using CATALINA_HOME: /java/tomcat/apache-tomcat-9.0.0.M17
Using CATALINA_TMPDIR: /java/tomcat/apache-tomcat-9.0.0.M17/temp
Using JRE_HOME: /java/jdk1.8.0_121
Using CLASSPATH: /java/tomcat/apache-tomcat-9.0.0.M17/bin/bootstrap.jar:/java/tomcat/apache-tomcat-9.0.0.M17/bin/tomcat-juli.jar
Tomcat started.

虚拟机的ip地址为192.168.1.202

查看tomcat

关闭tomcat,直接执行bin下面的shutdown.sh文件

hongdada@ubuntu:~$ cd /java
hongdada@ubuntu:/java$ cd tomcat
hongdada@ubuntu:/java/tomcat$ cd apache-tomcat-9.0.0.M17
hongdada@ubuntu:/java/tomcat/apache-tomcat-9.0.0.M17$ sudo ./bin/shutdown.sh
[sudo] hongdada 的密码:
Using CATALINA_BASE: /java/tomcat/apache-tomcat-9.0.0.M17
Using CATALINA_HOME: /java/tomcat/apache-tomcat-9.0.0.M17
Using CATALINA_TMPDIR: /java/tomcat/apache-tomcat-9.0.0.M17/temp
Using JRE_HOME: /java/jdk1.8.0_121
Using CLASSPATH: /java/tomcat/apache-tomcat-9.0.0.M17/bin/bootstrap.jar:/java/tomcat/apache-tomcat-9.0.0.M17/bin/tomcat-juli.jar
hongdada@ubuntu:/java/tomcat/apache-tomcat-9.0.0.M17$

为了每次能够在开机的时候自动启动tomcat

修改/etc/rc.local文件

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing. #set java environment
export JAVA_HOME=/java/jdk1.8.0_121
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH #tomcat
export TOMCAT_HOME=/java/tomcat/apache-tomcat-9.0.0.M17 #configuration
/java/tomcat/apache-tomcat-9.0.0.M17/bin/startup.sh

特别是#configuration下面的,用于自启动。

重启以后发现tomcat并没有自动启动,网上查看发现原来我的/etc/rc.local没有执行权限

hongdada@ubuntu:~$ ls -al /etc/rc.local
-rw-rw-r-- 1 root root 628 3月 2 23:15 /etc/rc.local
hongdada@ubuntu:~$ chmod +x /etc/rc.local
chmod: 更改'/etc/rc.local' 的权限: 不允许的操作
hongdada@ubuntu:~$ sudo chmod +x /etc/rc.local
hongdada@ubuntu:~$ ls -al /etc/rc.local
-rwxrwxr-x 1 root root 628 3月 2 23:15 /etc/rc.local
hongdada@ubuntu:~$

修改/etc/rc.local的执行权限,重启发现tomcat已经ok了。

http://www.linuxidc.com/Linux/2017-02/140908.htm

http://www.linuxdiyf.com/linux/27852.html

http://blog.csdn.net/jacson_bai/article/details/45149431

Ubuntu16.04 安装JDK Tomcat的更多相关文章

  1. ubuntu16.04安装jdk,tomcat

    ubuntu16.04安装jdk,tomcat 最近装了一下tomcat,网上的教程很多,我也试了很多次,但是有一些教程关于tomcat配置是错误的,让我走上了歧途.差点重装系统,还好王总及时出手帮助 ...

  2. ubuntu16.04安装jdk/mysql/tomcat (使用apt-get命令)

    安装jdk 更新系统安装包缓存,并且安装OpenJDK8 sudo apt-get update sudo apt-get install openjdk-8-jdk 检查jdk版本 java -ve ...

  3. Ubuntu server12.04安装JDK+Tomcat+mysql

    一.安装JDK 1.首先到官网上下载jdk-7u79-linux-x64.tar.gz. 2.将jdk-7u79-linux-x64.tar.gz拷贝到/usr/lib/jdk/目录下面,这里如果没有 ...

  4. Ubuntu16.04安装JDK

    转载请注明源出处:http://www.cnblogs.com/lighten/p/6105463.html 1.简单的安装方法 安装JDK的最简单方法应该就是使用apt-get来安装了,但是源一般是 ...

  5. Ubuntu16.04 安装 JDK

    1.到Oracle官网下载 地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html ...

  6. ubuntu16.04 安装jdk 错误解决

    错误 $ apt-get install openjdk-9-jdk Errors were encountered while processing: /var/cache/apt/archives ...

  7. Ubuntu16.04 安装openjdk-7-jdk

    Ubuntu16.04 安装openjdk-7-jdk sudo apt-get install openjdk-7-jre 或者sudo apt-get install openjdk-7-jdk ...

  8. RedHat Linux 5.5安装JDK+Tomcat并部署Java项目

    与大家分享下RedHat Linux 5.5安装JDK+Tomcat并部署Java项目的步骤,希望对大家有用. 1.下载并安装jdk 虚拟机中安装RedHat Linux 5.5 64位企业版, 这里 ...

  9. Ubuntu16.04安装Ambari 2.7.3

    概念了解 Ambair介绍 Apache Ambari是一个用于支持大数据软件供应 管理与监控软件.它也是一个分布式软件,分为Ambair-Server与Ambari-Client两个部分.在生产环境 ...

随机推荐

  1. java基础---->Base64算法的使用

    Base64是网络上最常见的用于传输8Bit字节代码的编码方式之一,可用于在HTTP环境下传递较长的标识信息.详细的Base64信息,可以参见维基百科:https://en.wikipedia.org ...

  2. VScode之JavaScript Snippet Pack

    一个片段包 使用例如: cl 回车或者tab键,就可以完整的打出console.log("") 还有很多快捷功能: 参考: https://marketplace.visualst ...

  3. EUI组件之BitmapLabel 位图字体

    一.制作文图字体文件 使用TextureMerger制作位图字体,具体查看 官方教程. 我们这里制作了一组位图字体. 二.导入位图字体 位图字体素材放入资源配置文件default.res.json 三 ...

  4. js对字符串进行加密和解密方法!

    在做一些微信小程序,或混合 app 的时候,或者是考虑到一些 JS 数据安全的问题.可能会使用到 JS 对用户信息进行缓存. 例如在开发:微信小程序对用户进行加密缓存,开发混合APP对用户信息进行加密 ...

  5. 170804、使用Joda-Time优雅的处理日期时间

    简介 在Java中处理日期和时间是很常见的需求,基础的工具类就是我们熟悉的Date和Calendar,然而这些工具类的api使用并不是很方便和强大,于是就诞生了Joda-Time这个专门处理日期时间的 ...

  6. DetaSet更新数据

    用到的控件:DataGridView(展示数据),                    Button控件,更名[更新] using System; using System.Collections. ...

  7. codeforces#510 Div2

    pre过了三题 后来A题被hack了 B题终测挂了 两题其实都是有一个小细节没有处理好 中间C还因为cinT了一次 唉本来打的还不错的 还是太菜了 继续加油吧 A-Benches 有n张椅子 原来第i ...

  8. Oracle等待事件之Enqueue(锁)

    1.产生原因 表示与内部队列机制相关的等待,例如对保护内部资源或者组件的锁的请求等,一种并发的保护机制,该等待意味着在访问同样的数据库资源时需要等待其他会话已经获取的锁. 2.确定产生问题的对象 死锁 ...

  9. 您好,python的请求es的http库是urllib3, 一个请求到贵司的es节点,想了解下,中间有哪些网关啊?冒昧推测,贵司的部分公共网关与python-urllib3的对接存在异常?

    您好,python的请求es的http库是urllib3, 一个请求到贵司的es节点,想了解下,中间有哪些网关啊?冒昧推测,贵司的部分公共网关与python-urllib3的对接存在异常? 负载均衡( ...

  10. 第二次作业(WordCount)

    1 Github项目地址:https://gitee.com/DamonGetup/WordCount/tree/master 2 对程序设计语言源文件统计字符数.单词数.行数,统计结果以指定格式输出 ...