blog.itcode.devblog.itcode.dev

Running Tomcat in the Current Console Window

Mr. A is starting up Tomcat like any other day. Tomcat, which had been working fine until yesterday, immediately shuts down during startup due to some error. Right before it closed, some kind of error message seemed to flash by... but it happened too fast to catch. Mr. A has no choice but to dig through the logs one by one to fix the error. Nothing was changed on his end, so why is this happening?

Running Tomcat in the Current Console Window

Mr. A is starting up Tomcat like any other day. Tomcat, which had been working fine until yesterday, immediately shuts down during startup due to some error. Right before it closed, some kind of error message seemed to flash by... but it happened too fast to catch. Mr. A has no choice but to dig through the logs one by one to fix the error. Nothing was changed on his end, so why is this happening?
RWB0104
@RWBwritten at 2021-05-26 07:32:16

Mr. A is starting up Tomcat like any other day. Tomcat, which had been working fine until yesterday, immediately shuts down during startup due to some error. Right before it closed, some kind of error message seemed to flash by... but it happened too fast to catch. Mr. A has no choice but to dig through the logs one by one to fix the error. Nothing was changed on his end, so why is this happening?

It's true that Tomcat runs as a console-style process, but if you look closely at how it actually runs, it's a bit different. When you run startup.bat, a cmd window opens, then closes, and immediately after, the Tomcat window appears. Because a brand-new window always opens when Tomcat starts, if Tomcat stops due to an error, that window immediately closes as well.

There is a fix — a simple edit to startup.bat lets you make Tomcat run in the current window instead.

Open startup.bat in Notepad, and near the bottom you'll find the line call "%EXECUTABLE%" run %CMD_LINE_ARGS%. Change the run in the middle to start.

In other words, change the line to call "%EXECUTABLE%" start %CMD_LINE_ARGS% and save it.

From then on, instead of double-clicking startup.bat to run it, open a cmd window first, and then call startup.bat from that console. This way, no new window opens, and Tomcat runs within the console you launched it from.
Since the console window won't close even if Tomcat shuts down, you can comfortably check the messages.

# WAS# Tomcat# Console
ship
blog.itcode.dev

Notes from the π-th Alpaca

7.0.1
Developed by RWB since 2021.057th upgraded at 2026.08