IntelliJ IDEA 2023.3 Help

Java Scratch run configuration

Use the Java Scratch run/debug configuration to run and debug Java scratch files that have the main() method defined.

Common options

Name

Specify a name for the run configuration to quickly identify it among others when editing or running.

Allow multiple instances

Allow running multiple instances of this run configuration in parallel.

By default, it is disabled, and when you start this configuration while another instance is still running, IntelliJ IDEA suggests stopping the running instance and starting another one. This is helpful when a run configuration consumes a lot of resources and there is no good reason to run multiple instances.

Store as project file

Save the file with the run configuration settings to share it with other team members. The default location is .idea/runConfigurations. However, if you do not want to share the .idea directory, you can save the configuration to any other directory within the project.

By default, it is disabled, and IntelliJ IDEA stores run configuration settings in .idea/workspace.xml.

Main options

Main class

Specify the name of the Java class from a scratch file that you want to execute (pass to the JRE).

Path to scratch file

Specify the path to the scratch file.

VM options

Specify the options to be passed to the Java virtual machine when launching the application, for example, -mx, -verbose, and so on.

When specifying JVM options, follow these rules:

  • Use spaces to separate individual options.

  • If the value of an option includes spaces, enclose either the value or the actual spaces with double quotes.

  • If an option includes double quotes as part of the value, escape the double quotes using backslashes.

  • You can pass environment variable values to custom Java properties.

-Xmx1024m -Dspaces="some arg" -Dmy.prop=\"quoted_value\" -Dfoo=${MY_ENV_VAR}

Use code completion in this field: start typing the name of a flag, and the IDE suggests a list of available command line options. This works for -XX: and -X options and some standard options that are not configured by IntelliJ IDEA automatically, like -ea, but not for -cp or –release.

The -classpath option specified in this field overrides the classpath of the module.

Program arguments

Specify a list of arguments to be passed to the application in the format you would use on the command line. Use the same rules as for specifying VM options.

Working directory

Specify the working directory to be used for running the application. This directory is the starting point for all relative input and output paths. By default, the working directory is the project root.

Environment variables

Specify environment variables that are necessary for running the application.

Redirect input from

Read input from the specified text file.

The path is relative to the working directory unless you specify an absolute path.

Click the Insert Macros button to use macros. You can also use path variables in this field.

Use classpath of module

Select the module whose classpath should be used to run the application.

Add dependencies with “provided” scope to classpath

Add the dependencies with the provided scope to the runtime classpath.

JRE

Specify the runtime environment that IntelliJ IDEA should use to run the application. By default, IntelliJ IDEA uses the latest available JDK from the module dependencies.

Shorten command line

Select the method for shortening the command line if the classpath gets too long, or if you have so many VM arguments that they exceed your OS command line length limitation:

  • none: IntelliJ IDEA will not shorten a long classpath. If the command line exceeds the OS limitation, IntelliJ IDEA will be unable to run your application and will display a message suggesting you to specify the shortening method.

  • JAR manifest: IntelliJ IDEA will pass a long classpath via a temporary classpath.jar. The original classpath is defined in the manifest file as a class-path attribute in classpath.jar. You will be able to preview the full command line if it was shortened using this method, not just the classpath of the temporary classpath.jar.

  • classpath file: IntelliJ IDEA will write a long classpath into a separate text file.

Before launch

Specify a list of tasks to perform before starting the run configuration. For example, run another configuration, build the necessary artifacts, run some external tool or a web browser, and so on.

Click the Add button or press Alt+Insert to add one of the available tasks.

Move tasks in the list using the Up button and the Down button to change the order in which to perform the tasks. Select a task and click the Edit button to edit the task. Click the Remove button to remove the selected task from the list.

Show this page

Show the run configuration settings before actually starting it.

Activate tool window

Depending on the type of configuration, open the Run, Debug, or Services tool window when you start this run configuration. If this option is disabled, you can open the tool window manually:

  • View | Tool Windows | Run or Alt+4

  • View | Tool Windows | Debug or Alt+5

  • View | Tool Windows | Services or Alt+8

Last modified: 19 March 2024