Ubuntu通常有两个JDK可供选择(OpenJDK和OracleJDK/SunJDK(以下简称OracleJDK)),OpenJDK是社区版本,OracleJDK是官方版。
Oracle官网下载页提供各个OracleJDK的下载版本 : 本文下载安装jdk-8u172
# 解压到/usr/lib/jvm中
$ sudo mkdir /usr/lib/jvm
$ sudo tar zxvf Downloads/jdk-8u172-linux-x64.tar.gz -C /usr/lib/jvm
# 配置环境变量,在bashrc中添加变量path
$ sudo vim ~/.bashrc
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_172
export CLASSPATH=${JAVA_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
# 使bashrc立刻生效
$ source ~/.bashrc
检查安装版本 :
$ java -version
java version "1.8.0_172"
Java(TM) SE Runtime Environment (build 1.8.0_172-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode)
$ javac -version
javac 1.8.0_172
如果有多个版本的JDK,可以用sudo update-alternatives --config java
进行切换 。
MySQL官网安装说明页提供了APP源安装方法:
#1.Adding the MySQL APT Repository (没用,可以省略)
#2.Installing MySQL with APT (只需这一步即可)
$ sudo apt-get install mysql-server
#3.Starting and Stopping the MySQL Server (开启和关闭sql)
$ sudo service mysql stop
$ sudo service mysql start
提示: 如果是Ubuntu18.04安装MySQL,因为版本问题,请移步https://blog.csdn.net/zyqblog/article/details/80159990
个人喜欢直接用终端操作数据库:
$ mysql -uroot -p123456 # 连接本机数据库
Apache Tomcat官网下载页 提供了Tomcat版本的下载:本文下载apache-tomcat-9.0.7.tar.gz
# 解压到opt
$ sudo tar zxvf Downloads/apache-tomcat-9.0.7.tar.gz -C /opt/
# 更改文件权限
$ sudo chmod 777 -R /opt/apache-tomcat-9.0.7/
# 配置环境变量,在startup.sh和shutdown.sh文件的最后一行前加入环境变量的配置
$ sudo vim /opt/apache-tomcat-9.0.7/bin/startup.sh
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_172
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:%{JAVA_HOME}/lib:%{JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
export TOMCAT_HOME=/opt/apache-tomcat-9.0.7
exec "$PRGDIR"/"$EXECUTABLE" start "$@" # 这是文件最后一行
开启Tomcat :
# 启动Tomcat
$ cd /opt/apache-tomcat-9.0.7/bin/
$ sudo ./startup.sh
Using CATALINA_BASE: /opt/apache-tomcat-9.0.7
Using CATALINA_HOME: /opt/apache-tomcat-9.0.7
Using CATALINA_TMPDIR: /opt/apache-tomcat-9.0.7/temp
Using JRE_HOME: /usr/lib/jvm/jdk1.8.0_172/jre
Using CLASSPATH: /opt/apache-tomcat-9.0.7/bin/bootstrap.jar:/opt/apache-tomcat-9.0.7/bin/tomcat-juli.jar
Tomcat started.
# 浏览器访问http://localhost:8080/可以看到Tomcat主页
关闭Tomcat:
# 关闭Tomcat
$ sudo ./shutdown.sh
Using CATALINA_BASE: /opt/apache-tomcat-9.0.7
Using CATALINA_HOME: /opt/apache-tomcat-9.0.7
Using CATALINA_TMPDIR: /opt/apache-tomcat-9.0.7/temp
Using JRE_HOME: /usr/lib/jvm/jdk1.8.0_172/jre
Using CLASSPATH: /opt/apache-tomcat-9.0.7/bin/bootstrap.jar:/opt/apache-tomcat-9.0.7/bin/tomcat-juli.jar
Eclipse官网下载页提供了eclipse各个版本的下载,本文下载Jave EE 。
# 安装软件
$ sudo tar zxvf Downloads/eclipse-jee-oxygen-3a-linux-gtk-x86_64.tar.gz -C /opt
# 创建Dash Home图标
$ sudo touch /usr/share/applications/eclipse.desktop
$ sudo chmod 777 /usr/share/applications/eclipse.desktop
# 在eclipse.desktop中添加路径
$ sudo vim /usr/share/applications/eclipse.desktop
[Desktop Entry]
Type=Application
Terminal=false
Exec=/opt/eclipse/eclipse -desktop
Name=Eclipse
Icon=/opt/eclipse/icon.xpm
在Dash中有了Eclipse的软件启动图标,启动可能会提示如下错误:
# 错误提示
A Java Runtime Environment (JRE) or Java Development Kit (JDK)
must be available in order to run Eclipse. No Java virtual machine
was found after searching the following locations:
/opt/eclipse/jre/bin/java
java in your current PATH
# 错误原因
JDk安装在/usr/lib/jvm下,而eclipse安装在/opt下,导致Eclipse启动找不到JDK
# 解决办法,把JDK目录软连接到Eclipse目录下
$ ln -s /usr/lib/jvm/jdk1.8.0_172/jre/ /opt/eclipse/jre
在Eclipse中的window,perferences,server,Runtime Environments中部署Tomcat即可。
1.https://www.cnblogs.com/seaweedman/p/5994006.html
2.http://www.cnblogs.com/EasonJim/p/7139275.html