MPS 2023.3 Help

Run/debug configuration: Application

This run/debug configuration is the most common template for Java, which corresponds to compiling your program with javac and then running it with java.

Open the run configuration

  1. In the main menu, go to Run | Edit Configurations.

  2. In the Run/Debug Configuration dialog:

    • To create a new configuration, click Add on the toolbar or press Alt+Insert and select Application.

    • Alternatively, click an existing Application configuration in the list on the left.

    On the right, you will see configuration options.

Required options

Item

Description

JRE

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

Main class

Specify the fully qualified name of the class to be executed (passed to the JRE).

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.

More options

Operating system

Item

Description

Allow multiple instances

Allow multiple instances of this run configuration to execute at the same time. By default, this option is disabled, which means that when you run the configuration, other active sessions of the configuration will terminate.

Environment variables

Click the Browse button to open the Environment Variables dialog where you can create variables and specify their values.

Redirect input

Enables redirecting data from a text file to standard input. Use this option if your script requires some input, and you want to automatically submit the values instead of typing them in the Run console. To enable redirecting, select the checkbox and specify the path to the target text file.

Java

The following options are specific to the Java compiler and runtime:

Item

Description

Do not build before run

Run the application straight away without launching the build process.

Use classpath of module

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

Modify classpath

If necessary, specify another classpath or select dependencies that you want to exclude from the classpath. This option is necessary in cases when the runtime classpath is different from the compile classpath (debug libraries, different locations, and so on).

Use the Up and Down buttons to sort dependencies on the list. The order of dependencies is important as MPS will process them in the same order as they are specified in the list.

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

Shorten command line

Select a method that will be used to shorten the command line if the classpath gets too long, or you have many VM arguments that exceed your OS command line length limitation. The choice of option depends on the class loader implementation. Note that some frameworks do not support JAR manifest, while other frameworks with custom class loaders will not work well with the classpath.file option.

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

  • JAR manifest: MPS 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. Note that 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: MPS will write a long classpath into a text file.

  • @argFiles (java 9+): the command-line length limitations will be overcome using the @argument files option.

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 MPS automatically, like -ea, but not for -cp or –release.

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

Last modified: 07 March 2024