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
InstallationFrom VS Code Marketplace
Build from Source1. 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) |
instanceName |
default |
Default instance name (used for the .vscode/tomcat/<name>/ folder) |
|
servers |
[] |
Multi-instance list — leave empty for a single instance (see Multiple Instances) | |
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) |
Multiple Instances
You can run several Tomcat instances on different ports at the same time. When servers is empty, a single instance runs from the flat settings (port/debugPort); fill in the list and each entry becomes its own instance. You can also add one via the + button (Add Instance) in the sidebar.
{
"tomcatAutoDeploy.servers": [
{ "name": "default", "port": 8080 },
{ "name": "staging", "port": 8081 }
]
}
Per-instance keys: name, port (required), debugPort, redirectPort, javaHome, catalinaHome, javaOpts.
- Omitted ports are auto-calculated — debug
5005 + (port - 8080), redirect8443 + (port - 8080) - Omitted
javaHome/catalinaHome/javaOptsfall back to the shared settings - Each instance gets its own base under
.vscode/tomcat/<name>/ - When instances share a deployment target, files are synced once and only HotSwap runs per instance
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: Start All | Start every instance |
| Tomcat: Stop All | Stop every instance |
| Tomcat: Pick Instance | Select the target instance for save-on-deploy and the status bar |
| Tomcat: Add Instance | Add a new instance to the servers setting |
| Tomcat: Remove Instance | Remove the selected instance from the servers setting |
| Tomcat: Delete Orphan Folder | Delete a .vscode/tomcat/<name>/ folder no longer in your settings |
| 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: Open context.xml | Open the generated context.xml for editing |
| Tomcat: Deploy All | Re-run full sync (Ctrl+Alt+D) |
| Tomcat: Build & Deploy | Run Maven/Gradle compile, then full sync (available when stopped, Maven/Gradle projects only) |
| Tomcat: Sync Web/Resources | Deploy static files (JSP/HTML/CSS/JS/images) only, without recompiling Java |
| 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. Multiple instances appear as individual tree items, each with its own start/stop/restart/force-stop/open-browser/open-config actions. An instance whose HotSwap failed is flagged with an error icon and a "restart required" hint.

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, and the affected instance in the sidebar tree is flagged with an error icon and a "restart required" hint. 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) - Generated sources under
target/generated-sources/(ANTLR, QueryDSL, etc.) are automatically included in compilation - If javac fails at startup, the extension automatically runs
mvn compileand retries - 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 - Generated sources under
build/generated/sources/are automatically included in compilation - If javac fails at startup, the extension automatically runs
gradle classesand retries - 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
javaOptssetting includes encoding options such as-Dfile.encoding=UTF-8by default (editable as needed)
License
This project is licensed under the Apache License 2.0.
