# Java Scratch run configuration

> **TL;DR**
> Create: `Run | Edit Configurations |` ![Add New Configuration](https://resources.jetbrains.com.cn/help/img/idea/2026.2/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.      ```PLAINTEXT -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](#working_directory) unless you specify an absolute path.                           Click ![the Insert Macros button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.general.add_dark.svg) to use [macros](built-in-macros.html). You can also use [path variables](absolute-path-variables.html) in this field.                           > **Tip:** > If you want IntelliJ IDEA to ask you to choose an input file every time you run the application, use the `$FilePrompt$` macro, which invokes the file selection dialog on every launch.    |
| 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](sdk.html#define-sdk) 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 that you 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](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.add.svg) or press `Alt+Insert` (Windows), `⌘ N` (macOS), `⌃ N` (IntelliJ IDEA Classic (macOS)), `⌘ N` (macOS System Shortcuts), `Alt+Insert` (XWin), `Alt+Insert` (GNOME), `Alt+Insert` (KDE), `Alt+Insert` (Emacs), `Ctrl+N` (Sublime Text), `⌘ N` (Sublime Text (macOS)), `Alt+Insert` (NetBeans), `Ctrl+N` (Visual Studio), `⌘ N` (Visual Studio (macOS)), `Alt+Insert` (Eclipse), `⌘ N` (Eclipse (macOS)) to add one of the available tasks.

Move tasks in the list using ![the Up button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.moveUp.svg) and ![the Down button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.moveDown.svg) to change the order in which to perform the tasks. Select a task and click ![the Edit button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.edit.svg) to edit the task. Click ![the Remove button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.remove.svg) 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](run-tool-window.html), [Debug](debug-tool-window.html), or [Services](services-tool-window.html) 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` (Windows), `⌘ 4` (macOS), `⌘ 4` (IntelliJ IDEA Classic (macOS)), `⌘ 4` (macOS System Shortcuts), `Alt+4` (XWin), `Alt+4` (GNOME), `Alt+4` (KDE), `Alt+4` (Emacs), `Alt+4` (Sublime Text), `⌘ 4` (Sublime Text (macOS)), `Alt+4` (NetBeans), `Alt+4` (Visual Studio), `⌘ 4` (Visual Studio (macOS)), `Alt+4` (Eclipse), `⌘ 4` (Eclipse (macOS))    * `View \| Tool Windows \| Debug` or `Alt+5` (Windows), `⌘ 5` (macOS), `⌘ 5` (IntelliJ IDEA Classic (macOS)), `⌘ 5` (macOS System Shortcuts), `Alt+5` (XWin), `Alt+5` (GNOME), `Alt+5` (KDE), `Alt+5` (Emacs), `Alt+5` (Sublime Text), `⌘ 5` (Sublime Text (macOS)), `Alt+5` (NetBeans), `Alt+5` (Visual Studio), `⌘ 5` (Visual Studio (macOS)), `Alt+5` (Eclipse), `⌘ 5` (Eclipse (macOS))    * `View \| Tool Windows \| Services` or `Alt+8` (Windows), `⌘ 8` (macOS), `⌘ 8` (IntelliJ IDEA Classic (macOS)), `⌘ 8` (macOS System Shortcuts), `Alt+8` (XWin), `Alt+8` (GNOME), `Alt+8` (KDE), `Alt+8` (Emacs), `Alt+8` (Sublime Text), `⌘ 8` (Sublime Text (macOS)), `Alt+8` (NetBeans), `Alt+8` (Visual Studio), `Alt+8` (Visual Studio (macOS)), `Alt+8` (Eclipse), `⌘ 8` (Eclipse (macOS))     |

## See also

### Concepts

[Run/debug configurations](run-debug-configuration.html)

### Procedures

[Scratch files](scratches.html)

