Java and Kotlin by IntelliJ IDEA Help

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.

The Run icon in the editor

Start a debug session

  1. 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.

  2. 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.

  1. Add the IntelliJ: Launch main class configuration to launch.json and save the changes.

    Adding a new IntelliJ: Launch main class run configuration in VS Code
  2. Select the Run main configuration in the Run and Debug view.

  3. 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:

mainClass

Required. The fully qualified name of the class with the main method.

file

Path 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.

classPaths

Runtime classpath. If omitted, Java and Kotlin by IntelliJ IDEA resolves it automatically.

javaExec

Path to the java launcher. If omitted, Java and Kotlin by IntelliJ IDEA resolves it automatically.

modulePaths

JPMS module path.

vmArgs

JVM arguments placed before the main class, for example -Xmx512m or -ea.

args

Program arguments passed to main(String[]).

cwd

Working directory.

env

Additional 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.

  1. Start the target JVM with JDWP enabled by adding the following VM option:

    -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005
  2. Add the IntelliJ: Attach to JVM configuration to launch.json, set port to the port the JVM listens on (5005 in the example), and save the changes.

  3. 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:

port

Required. The JDWP port that the target JVM is listening on. Default: 5005.

hostName

The host that the target JVM is listening on. Default: localhost.

timeout

Connection 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.

28 July 2026