Path Variables dialog has nothing to do with the environment variables.

Environment variables can be specified in your OS or customized in the Run configuration:

If you want to specify default environment variables for every new unit test configuration (as per this answer):

Run > Edit Configurations > Edit Configuration Templates > TestNG/JUnit > Environment Variables

Answer from CrazyCoder on Stack Overflow
🌐
LaunchCode
education.launchcode.org › gis-devops › configurations › 02-environment-variables-intellij › index.html
Configuration: Environment Variables - IntelliJ — LaunchCode: GIS DevOps documentation
This tells IntelliJ to use the environment variable in place of this token. In this case I will be using the DataBase environment variables to configure this application with my database. Within the application.properties file · I am using the application.properties file to configure my database. In the first line we are configuring the JDBC (Java ...
Discussions

IntelliJ IDEA global environment variable configuration - Stack Overflow
I need to use an environment variable in all of my idea run configurations. I currently use run->edit configurations->and then enter the env variables in selected configuration. However, that's More on stackoverflow.com
🌐 stackoverflow.com
November 18, 2019
java - How do I add environment variables in IntelliJ Spring Boot project - Stack Overflow
I Am trying to add an environmental variable inside my spring-boot application.properties file. I know how to add it normally on a non spring-boot project, but I cannot find the field for adding More on stackoverflow.com
🌐 stackoverflow.com
java - IntelliJ - why does the terminal has different environment variables values - Stack Overflow
Edit: The best solution is to not define a JRE_HOME environment variable. I don’t know why but IntelliJ stucks using that env variable. ... Same for me. I can confirm that on Windows 10 I had to restart the machine. Restarting IntelliJ IDEA had no effect ... 2020-04-09T11:30:08.573Z+00:00 ... when a java... More on stackoverflow.com
🌐 stackoverflow.com
IntelliJ : executing a program with environment variables stored in a separated file - Stack Overflow
My application needs custom environment variables to run. I have created a run configuration in IntelliJ in order to start the application. For environment variables, I have set VM options. Example... More on stackoverflow.com
🌐 stackoverflow.com
🌐
JetBrains
jetbrains.com › help › idea › program-arguments-and-environment-variables.html
Program arguments, VM options, environment variables | IntelliJ IDEA Documentation
May 27, 2025 - For quick configuration – type the environment variables directly into the Environment variables field, using the following format: VAR1=ABC;VAR2=CDE.
🌐
Twilio
twilio.com › en-us › blog › set-up-env-variables-intellij-idea-java
Configure Environment Variables in IntelliJ IDEA | Twilio
July 3, 2024 - In the Environment variables section as seen below, copy and paste the following, replacing the values with your own. Be sure to separate the variables with semicolons: ... Specify a module by clicking on the box to view the options in the dropdown.
🌐
Medium
medium.com › @AlexanderObregon › working-with-environment-variables-in-intellij-idea-a-guide-12876bb796c5
Working with Environment Variables in IntelliJ IDEA — A Guide
April 28, 2024 - In this guide, we’ll delve into ... Environment variables are essentially key-value pairs that exist outside the application and are used to pass configuration information to it....
🌐
Readthedocs
technicalwritingproject2.readthedocs.io › en › latest › pages › setup.html
Setup — Intellij Manual 0 documentation
In the second section titled System Variables, click the New button to add a new environment variable. In the box that pops open, you need to provide both the Variable name and Variable value. Insert JAVA_HOME`as the `Variable name and insert the path to your JDK directory as the Variable value.
Find elsewhere
🌐
CodingTechRoom
codingtechroom.com › tutorial › java-how-to-set-and-use-environment-variables-in-intellij-idea-for-java-development
Configuring Environment Variables in IntelliJ IDEA for Java Development - CodingTechRoom
Environment variables are crucial ... managing these variables properly can save you time and prevent errors. ... Open your project in IntelliJ IDEA and navigate to the main toolbar....
🌐
JetBrains
jetbrains.com › help › idea › tuning-the-ide.html
Advanced configuration | IntelliJ IDEA Documentation
If the Toolbox App manages your current IntelliJ IDEA instance, open the Toolbox App, click next to the relevant IDE instance, and select Settings. Under Configuration, find Java ...
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 205820189-How-to-set-default-environment-variables-
How to set "default" environment variables? – IDEs Support (IntelliJ Platform) | JetBrains
May 3, 2017 - Please, go to `Run| Edit Configurations| Defaults| Python tests| Unitests/Nosetests/...` and specify your environment variables in "Environment variables" field, then apply changes.
Top answer
1 of 11
26

In my opinion the real issue is what Mat said. If you want to launch IntelliJ from a shortcut, then you have to edit it a little bit: Open the .desktop file, and add /bin/bash -c -i to the beginning of the launch command. The file should look something like this:

[Desktop Entry]
Exec=/bin/bash -i -c "/path/to/idea/bin/idea.sh" %f
Name=IntelliJ IDEA Ultimate
Type=Application
Version=1.0

The desktop file in ubuntu can be located at:

  • .local/share/applications/jetbrains-idea-ce.desktop

If the IDEA is installed via snap, then copying the desktop file is needed:

cp /var/lib/snapd/desktop/applications/intellij-idea-ultimate_intellij-idea-ultimate.desktop ~/.local/share/applications/

After editing the desktop file in ~/.local/share/applications/ the desktop menu should refresh itself in a few seconds.

2 of 11
19

I found a solution to set environment variables on IntelliJ that has been working very well for me, and is incredibly simple. Let me show you.

This is the program (you can copy and paste it) we're using to test:

package com.javasd.intelijenv;

import java.util.Map;

public class Main {
    public static void main(String[] args) {
        Map<String, String> env = System.getenv();
        for (String envName : env.keySet()) {
            System.out.format("%s=%s%n", envName, env.get(envName));
        }

        System.out.println("My home directory: " + System.getenv("MY_VAR"));
    }
}

This program basically loads all environment variables, show them on the console, and try to show an env variable. Also, it assumes that you had created the MY_VAR env variable before calling IntelliJ IDEA, by doing something like:

$ export MY_VAR="This is my adorable var :)"
$ idea

Please, notice that we're calling IntelliJ IDEA in the same terminal (or session, or window) where we created the environment variable. If you create the variable and call the IDEA from the icon, the solution won't work because the IDEA will create its own session.

So, if run it without the correct configuration you will get something line this in your console:

Please, notice that you have just a few variables, and that MY_VAR is null.

Here's configuration I use to load the environment variables:

  1. Click on the "Select Run/Debug Configurations" in your project and select "Edit Configurations":

  1. Then, click on the the button with "..." on the right side of the "Environment Variables" section:

  1. You'll see a pop-up. Check the checkbox on the bottom-left which has the label "Include parent environment variables":

That's it!!!

If you run your program now you will see something like this on your console:

You can see all the environment variables and, of course, your "MY_VAR" variable, with the right value!

Beyond the Basics

Usually, for security reasons, we don't want to keep all the environment variables visible. What we want to do is to make those variables visible only while the IntelliJ (or our program) is running.

So, no sensitive variables should be visible on the environment neither before you call Intellij nor after you close it.

Also, you want to keep those variables in a file (typically with a .env extension) to make it easy to manipulate and for security reasons.

To achieve this, there are some useful programs (you can Google them), but my favorite one is the env-cmd.

Let's say you have a test.env file with the following content:

MY_TEST_VAR=I live in the test.env file.

If you call IntelliJ by doing this:

$ env-cmd test.env idea

And edit your program to show "MY_TEST_VAR", and run it, you will see this on the IntelliJ's console:

But if you quit the IntelliJ, and look for your variable, you will see that the var doesn't exist (you can use env to confirm):

At this point, I hope you're able to play with your own solutions: create shell scripts with variables set inside, test other programs (direnv, autoenv, etc.), and so on.

🌐
Dploeger
dploeger.github.io › intellij-api-doc › com › intellij › util › EnvironmentUtil.html
EnvironmentUtil (Unofficial IntelliJ Community Edition API docs)
com.intellij.util.EnvironmentUtil · public final class EnvironmentUtil extends java.lang.Object · clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait · public static final java.lang.String BASH_EXECUTABLE_NAME · See Also: Constant Field Values · public static final java.lang.String SHELL_VARIABLE_NAME ·
🌐
DZone
dzone.com › coding › tools › gradle goodness: passing environment variables in intellij idea
Gradle Goodness: Passing Environment Variables in IntelliJ IDEA
December 16, 2016 - Actually, IntelliJ IDEA creates a new task of type JavaExec dynamically for our specific run configuration — with the main property set to the class we want to run. In the Edit Configuration dialog window, we can set the command line argument and Java system properties. These are passed on to the dynamically created JavaExec task and are accessible from within the class that runs. The environment variables that can be set in the Edit Configuration dialog windows are not passed to the JavaExec task configuration.
🌐
Totalcross
learn.totalcross.com › documentation › guides › package-your-app-from-scratch › environment-configuration › intellij
IntelliJ | TotalCross Platform
April 17, 2019 - To set the TOTALCROSS3_HOME (environment variable that points to the Totalcross SDK) in Eclipse is pretty simple, as you can see below: With your Maven project open, you will click on the "Run" option on the top bar of IntelliJ
🌐
JetBrains
jetbrains.com › help › idea › absolute-path-variables.html
Path variables | IntelliJ IDEA Documentation
Because such resources may be located in different places on each developer’s computer, user-defined path variables are stored as global IDE settings rather than project settings. The project stores only the variable name, while each developer defines its value locally. Once configured, a path variable has the same value for all projects opened in your instance of IntelliJ IDEA.