java_application
Manage Java app runtimes: launch, attach, restart, stop, or detach processes, with hotswap-aware restarts for Maven/Gradle projects.
Instructions
Launch, attach, restart, stop, or detach Java applications. For Maven/Gradle, use project_path plus main_class without IDEA, or select an IDEA launch. Use java_fast_test to run tests without launching an application. Launch and restart wait up to timeout (at most 30 seconds), returning the result if finished or the original background task if still running. After editing a managed Maven/Gradle project, use restart: it detects changed sources, incrementally compiles them, and prefers HotSwap (hotswap=true by default). Incompatible changes use the same compiled outputs to restart the JVM. Set hotswap=false for a real process restart and application reinitialization. apply_method reports hotswap or restart; HotSwap does not refresh framework state or count as a JVM startup. previous_startup_ms reports the prior successful startup duration saved locally for this launch, or null if unavailable. It survives MCP restarts and excludes compilation. A pending restart returns reload_id; observe active_operation and last_reload using java_status. Direct JAR/classpath launches restart their existing artifact without source compilation.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pid | No | Local Java PID required by attach. | |
| host | No | Debug connection host; localhost only. | 127.0.0.1 |
| action | Yes | Runtime operation to perform. | |
| hotswap | No | For restart, default true: incrementally compile edits and prefer HotSwap; if changes cannot be hot-swapped, restart the JVM with those compiled outputs. False forces a JVM restart after compilation. Use false to reinitialize application state or reload framework/startup configuration. No pending code changes also restart the JVM without recompiling. | |
| timeout | No | Seconds to wait for the launch/restart result in this call. Defaults to 30; values above 30 wait only 30 seconds without error. Zero returns immediately after submission. On expiry the same task continues in the background. | |
| vm_args | No | JVM arguments for launch/restart. Replaces imported or current arguments; [] clears them. | |
| app_args | No | Application arguments for launch/restart. Replaces imported or current arguments; [] clears them. | |
| jar_path | No | Executable JAR for direct launch/restart; omit with project_path. | |
| classpath | No | Classpath for direct launch/restart with main_class; omit with project_path. | |
| java_home | No | Application JDK home directory for project_path launch. | |
| jdwp_port | No | Local Java debug port for launch or attach. | |
| main_class | No | Fully qualified application entry class. With project_path, launch without requiring IDEA configuration; otherwise uses classpath. | |
| ready_port | No | Local application TCP port for launch/restart readiness; must differ from jdwp_port. | |
| launch_name | No | Optional exact case-sensitive IDEA launch configuration name; requires project_path. With main_class and no launch_name, no IDEA launch configuration is required. Explicit main_class, java_home, app_args and vm_args override imported values. | |
| build_system | No | Optional authoritative build system for project launch; specify maven or gradle when both exist. | |
| project_path | No | Maven or Gradle project directory. Supply main_class for an IDEA-independent launch, or import an IDEA launch configuration (launch_name selects one). Compiles changed sources before starting the application. Do not combine with direct jar_path or classpath. |