Run and debug
Java and Kotlin by IntelliJ IDEA lets you run and debug Java and Kotlin applications in VS Code, Cursor, or any other VS-Code-based editor. You can start from the editor, create a launch configuration to control how the application starts, or attach the debugger to a running JVM.
Build the project
Build the project before you run or debug an application so that the compiled classes include your latest changes. In the integrated terminal, run the build command for your build system:
- Gradle
- ./gradlew build
- Maven
- mvn compile
- Bazel
- bazel build //...
Run from the editor
Navigate to the entry point of your application in the editor and click Run.

Start a debug session
Set a breakpoint by clicking on an executable line in the gutter. This will suspend the application just when this line is about to execute. For more details about breakpoints in VS-Code-based editors, refer to the VS Code documentation.
Start the debug session by clicking the Debug link in the editor.
Java and Kotlin by IntelliJ IDEA suspends all application threads when any of them reaches the line with the breakpoint. The highlighted line has not been executed yet, so you can examine the program state at this point.
Create a launch.json configuration
Another way to run or debug a program is to use a launch configuration. It allows you to customize the startup: add arguments, custom commands, and environment variables.
Launch a main class
Use this configuration to run and debug your application.
Add the IntelliJ: Launch main class configuration to launch.json and save the changes.

Select the Run main configuration in the Run and Debug view.
Press ⌃ ⌥ R to run the application or press ⌘ \ to start a debug session.
In most cases, a minimal configuration is enough: specify the mainClass attribute, and Java and Kotlin by IntelliJ IDEA resolves the source file, classpath, and Java executable from the project model. If several classes with the same fully qualified name exist in the project, add the file attribute to point to the source file you want to run.
The launch configuration supports the following fields:
mainClassRequired. The fully qualified name of the class with the
mainmethod.filePath to the source file. If omitted, Java and Kotlin by IntelliJ IDEA resolves it automatically. Specify this field when multiple classes have the same
mainClass.classPathsRuntime classpath. If omitted, Java and Kotlin by IntelliJ IDEA resolves it automatically.
javaExecPath to the
javalauncher. If omitted, Java and Kotlin by IntelliJ IDEA resolves it automatically.modulePathsJPMS module path.
vmArgsJVM arguments placed before the main class, for example
-Xmx512mor-ea.argsProgram arguments passed to
main(String[]).cwdWorking directory.
envAdditional environment variables.
Attach to a running JVM
Use this configuration to connect the debugger to a JVM that is already running, on the local machine or on a remote host, over JDWP.
Start the target JVM with JDWP enabled by adding the following VM option:
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005Add the IntelliJ: Attach to JVM configuration to launch.json, set
portto the port the JVM listens on (5005in the example), and save the changes.Select the Attach to JVM configuration in the Run and Debug view and press ⌘ \ to start the debug session.
The configuration supports the following fields:
portRequired. The JDWP port that the target JVM is listening on. Default:
5005.hostNameThe host that the target JVM is listening on. Default:
localhost.timeoutConnection timeout in milliseconds. Default:
30000.
Limitations
Java and Kotlin by IntelliJ IDEA does not delegate execution to build tools. If you override launch parameters in a Gradle or Maven build script, Java and Kotlin by IntelliJ IDEA does not apply them. Maven and Gradle configurations that are not customized run as expected.
Running and discovering tests is not supported yet.