1、安装JDK,版本为1.8sudo apt-get install openjdk-8-jdk
查看版本java -version
2、下载Tomcatwget http://mirror.bit.edu.cn/apache/tomcat/tomcat-9/v9.0.31/bin/apache-tomcat-9.0.31.tar.gz
tar -zxvf apache-tomcat-9.0.31.tar.gz
设置开启自动启动sudo nano /etc/rc.local
在exit 0之前添加:/home/pi/apache-tomcat-9.0.31/bin/./startup.sh
3、常见错误
如果出现以下错误:Error occurred during initialization of VM
Server VM is only supported on ARMv7+ VFP
可以先通过以下命令查看处理器型号:cat /proc/cpuinfo
processor : 0
model name : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS : 697.95
Features : half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xb76
CPU revision : 7
Hardware : BCM2835
Revision : 9000c1
Serial : 00000000bc0bd4f4
Model : Raspberry Pi Zero W Rev 1.1
如果看到是ARMv6处理器(应该是树莓派ZERO系列),说明新版的JDK不支持
此时需要先把系统自带的JDK11卸载掉,再安装JDK8sudo apt-get purge openjdk-11-jdk
然后把软链接删掉,指向JDK8,应该就能解决问题rm /etc/alternatives/java
ln -s /usr/lib/jvm/java-8-openjdk-armhf/bin/java /etc/alternatives/java