IntelliJ IDEA 2025.1 Help

Program arguments, VM options, environment variables

You can configure program arguments, VM options, and environment variables for your Java application using run configuration settings.

Program arguments

  1. Open the run widget's menu. From the menu, select Edit Configurations.

  2. In the Run/Debug Configurations dialog, open the run configuration, for which you want to modify program arguments.

  3. In the run configuration settings, use the Program arguments field to pass arguments to your application.

    'Program arguments' field in run configuration settings

    If you want to use dynamic values from the context, such as the name of the currently opened file, use macros.

Environment variables

  1. Open the run widget's menu. From the menu, select Edit Configurations.

  2. In the Run/Debug Configurations dialog, open the run configuration, for which you want to modify environment variables.

  3. In the run configuration settings, use the Environment variables field to set the environment for your application:

    • For quick configuration – type the environment variables directly into the Environment variables field, using the following format: VAR1=ABC;VAR2=CDE.

    • For managing numerous environment variables in a table format and accessing system environment variables, click Edit environment variables in the Environment variables field.

    • For configuration through an .env file or a script – enter the path to the file or use the Browse for .env files and scripts button in the Environment variables field. In the case of multiple files, separate them with semicolons (;).

    'Environment variables' field in run configuration settings

Parent environment variables

You can reference existing variables, including the parent environment variables, using the $VAR$ syntax. Note that such references are case-sensitive: for example, PATH=xxx:$PATH$ for Linux/macOS and Path=xxx;$Path$ for Windows.

Environment scripts

You can set the environment for your program using a script.

Use the following syntax for setting variables in your script:

set VAR=value
export VAR=value

Note that the environment created by a script is applied only to a single launch of the corresponding configuration and takes precedence over custom values.

The specified script will run after all the Before Launch tasks.

VM options

  1. Open the run widget's menu. From the menu, select Edit Configurations.

  2. In the Run/Debug Configurations dialog, open the run configuration, for which you want to modify VM options.

  3. In the run configuration settings, click Modify Options, then select Add VM Options.

  4. Use the VM options field to specify options that you want to pass to the virtual machine.

    'VM Options' field in run configuration settings

    If you want to use dynamic values from the context, such as the name of the currently opened file, use macros.

Macros

In some of the run configuration fields, you can insert dynamic values from the context, such as clipboard content, the working directory, or a value from a prompt that will be shown before each launch.

  1. Click the Insert Macros button in the run configuration field.

    'Insert Macros' icon in the 'Program arguments' field
  2. Select the macro from the list and click Insert.

    'Macros' dialog showing the list of available macros and their preview

For the list and descriptions of available macros, refer to Built-in IDE macros.

Last modified: 27 May 2025