Tomcat Auto DeployA VS Code extension that automatically compiles and deploys your Java web application to a local Tomcat server every time you save a file — with zero restarts. Save a
How It Works
For static files (JSP, HTML, CSS, JS, images, etc.), saving simply copies the file to the Tomcat deployment directory — changes are reflected on the next browser refresh. Features
Installation1. Package
2. Install in VS CodeOption A) Install from UI:
Option B) Install from command line:
Getting Started1. Set
|
| Setting | Required | Default | Description |
|---|---|---|---|
catalinaHome |
Yes | — | Path to your Tomcat installation (CATALINA_HOME) |
javaHome |
Recommended | env var | Path to JDK (uses JAVA_HOME if not set) |
port |
8080 | HTTP port — debug/redirect ports are auto-calculated based on this value | |
debugPort |
5005 | JPDA debug port — auto-calculated from HTTP port when manual config is off | |
redirectPort |
8443 | SSL redirect port — auto-calculated from HTTP port when manual config is off | |
contextPath |
/ |
Web application context path | |
javaSourceRoot |
src/main/java |
Java source root (relative to workspace) | |
webContentRoot |
src/main/webapp |
Static files root (relative to workspace) | |
resourceRoot |
src/main/resources |
Resource path — .xml, .properties, etc. deployed to WEB-INF/classes (relative to workspace) |
|
manualPortConfig |
false |
Manual port config — when checked, debug/redirect ports are set manually. When unchecked, auto-calculated from HTTP port | |
classpath |
[] |
Additional JAR paths to include in compilation | |
javaOpts |
"" |
Extra JVM options passed to Tomcat (separated by newlines) |
Commands
Available from the Command Palette (Ctrl+Shift+P) and the sidebar:
| Command | Description |
|---|---|
| Tomcat: Start | Start Tomcat in debug mode |
| Tomcat: Stop | Gracefully stop Tomcat |
| Tomcat: Force Stop | Kill the Tomcat process immediately |
| Tomcat: Restart | Stop and start Tomcat |
| Tomcat: Open Browser | Open http://localhost:{port} in your browser |
| Tomcat: Show Output | Show the main log panel |
| Tomcat: Localhost Log | Show Tomcat's localhost.log in a dedicated panel |
| Tomcat: Open server.xml | Open the generated server.xml for editing |
| Tomcat: Deploy All | Re-run full sync (Ctrl+Alt+D) |
| Tomcat: Open Settings | Open workspace settings filtered to this extension |
Status Bar
| Display | Meaning |
|---|---|
▶ Tomcat |
Stopped — click to start |
● Tomcat (orange) |
Running — click to stop |
✔ Deploy: Foo.java |
File compiled and deployed successfully |
✖ Deploy: Foo.java (red) |
Compilation failed — check the Output panel |
Sidebar
The Tomcat panel in the Activity Bar provides quick access to all server controls, log panels, and settings.
HotSwap Limitations
JDWP HotSwap is a JVM feature with inherent limitations. Understanding what it can and cannot do will save you from confusion:
Works (no restart needed):
- Changing code inside a method body
- Modifying log statements, fixing bugs, tweaking logic
Doesn't work (Tomcat restart required):
- Adding or removing methods
- Adding or removing fields
- Changing method signatures
- Changing class hierarchy (extends/implements)
- Adding or removing lambda expressions (they compile to synthetic methods)
When HotSwap fails, you'll see a warning in the Output panel. Just restart Tomcat to pick up the changes.
Build Tool Integration
Maven
- Dependencies are resolved via
mvn dependency:build-classpathand cached - Java
source/targetversion is read frompom.xml(properties ormaven-compiler-pluginconfig) - Run
mvn compileonce before first use (the extension syncs fromtarget/classes) - Changing
pom.xmlautomatically invalidates the dependency cache
Gradle
- Dependencies are resolved via a temporary init script that prints
compileClasspath - Java version is read from
sourceCompatibility/targetCompatibilityorjavaToolchain - Run
gradle compileJavaonce before first use (the extension syncs frombuild/classes) - Changing
build.gradleorbuild.gradle.ktsautomatically invalidates the dependency cache
No Build Tool
If there's no pom.xml or build.gradle, the extension compiles all .java files directly with javac.
Good to Know
- The
.vscode/tomcat/directory is the local Tomcat base — add it to.gitignore - Tomcat's
servlet-apiand other libraries are automatically included in the classpath - Compilation errors are shown in the Output panel (
Tomcat Auto Deploy) - If VS Code crashes, the extension will detect the orphan Tomcat process on next startup and offer to kill it
- The extension starts Tomcat with
-Dfile.encoding=UTF-8to prevent encoding issues in logs
