Just do your best!!!

Tomcat自定义jre启动脚本

  1. 下载Tomcat8.
  2. 把jre目录拷贝到tomcat根目录下,改名为jre8.

windows: tomcat根目录下新建文件名_startup.bat内容如下:

@echo off
cd /d %~dp0
set _SRC_ROOT=%cd%
set JRE_HOME=%_SRC_ROOT%\jre8
set PATH=%PATH%;%JRE_HOME%\bin
if exist %_SRC_ROOT%\logs (
    rmdir /s/q logs
)
mkdir logs
if exist %_SRC_ROOT%\work (
    rmdir /s/q work
)
mkdir work

if exist %_SRC_ROOT%\temp (
    rmdir /s/q temp
)
mkdir temp
set JAVA_OPTS=-Xms512m -Xmx512m -Dfile.encoding=UTF-8 -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=128m
%_SRC_ROOT%\bin\startup.bat

linux: tomcat根目录下新建文件名_startup.sh内容如下:

#!/bin/sh 
_SRC_ROOT=$(dirname $(readlink -f $0))
cd ${_SRC_ROOT}

export JRE_HOME=${_SRC_ROOT}/jdk1.8.0_201
export PATH=${PATH};${JRE_HOME}/bin
if [ -d "logs" ]; then
    rm -rf logs
fi
mkdir logs

if [ -d "work" ]; then
    rm -rf work
fi
mkdir work

if [ -d "temp" ]; then
    rm -rf temp
fi
mkdir temp

export JAVA_OPTS="-Xms512m -Xmx512m -Dfile.encoding=UTF-8 -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=128m"
bash ./bin/startup.sh