As of March 14th 2017 it appears that someone has written a plugin which allows this.

Open settings, then select plugins In the search box search for “.env files support” and install it. After restarting IntelliJ you will have a new tab in the Run Configurations screen called EnvFile. The EnvFile tab will have a checkbox for enabling EnvFile support and a list where you can specify the env files you want to load prior to launching that specific run configuration; you need to set the env file option up for each run configuration.

I have a similar use case to yours and it works for me in specifying env files associated with a run configuration.

Additional Information on the plugin: https://plugins.jetbrains.com/plugin/7861-env-file

Answer from Angelo on Stack Overflow
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 10075122899986-How-to-use-env-or-envrc-files-to-pull-env-vars-for-run-debug-configurations
How to use .env or .envrc files to pull env vars for run/debug configurations? – IDEs Support (IntelliJ Platform) | JetBrains
February 13, 2023 - Then if I want to create a run/debug ... in the "Environment variables" section with their values. Isn't there a way to tell the run/debug configuration to obtain the env vars from my .env or .envrc instead? If I want to update a variable I have to do it in both places, as sometimes I run the code outside of the IDE. ... Please try out EnvFile plugin. ... I installed EnvFile in IntelliJ Ultimate, ...
🌐
Medium
tmaslen.medium.com › keeping-environment-variables-local-to-a-project-directory-on-the-terminal-and-with-intellij-c928c2016599
Keeping environment variables local to a project directory on the terminal and with IntelliJ | by Tom Maslen | Medium
September 13, 2017 - So this means you can store a single instance of all your environment variables in the .env file, and then with the simple bit of bash script below, read them into the .envrc file. // contents of .envrc #!/usr/bin/env bashfor line in $(cat .env); do eval “export $line” done · And so there you have it. The power of local environment variables, but with the convenience of storing them in one place for both the terminal and IntelliJ.
Discussions

IntelliJ : executing a program with environment variables stored in a separated file - Stack Overflow
As of January 2026, IntelliJ IDEA supports this natively — no plugin required (see: link). ... Save this answer. ... Show activity on this post. It depends: The feature to load environment variables for run configurations from files has been suggested and discussed for a lot of IntelliJ products. More on stackoverflow.com
🌐 stackoverflow.com
IntelliJ IDEA global environment variable configuration - Stack Overflow
See youtrack.jetbrains.com/iss... what environment IntelliJ IDEA can load on Linux. ... I know it is old question, but in case your env variables are secrets stored in a seperate key management tool like Hashicorp Vault, and you dont want to duplicate them in a local .env file, see my answer here stackoverflow.com/a/77335858/1594088 ... In my opinion the real issue is what Mat said. If you want to launch IntelliJ from a shortcut, ... More on stackoverflow.com
🌐 stackoverflow.com
Environment Variable Manager Plugin
nice, forgetting to update env bars across multiple run configurations catches me out all too often, keen to give this a go. More on reddit.com
🌐 r/IntelliJIDEA
2
8
May 6, 2025
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
🌐
Medium
medium.com › @robel.sharma › set-env-file-in-the-intellij-idea-for-seamless-configuration-usage-33b4edf3922a
How to set environment variable and configuration from a file in Intellij Idea | by Robel Sharma | Medium
September 21, 2023 - Here is an way where you can do it just by using a file and a plugin and this will be used only in the IntelliJ build and run. To do that create a .env file using your all the export. Make sure not to add the export command. Only the assignment or declaration. ... DC="local_cluster" SERVICE_NAME="NA" ENVIRONMENT="dev" SSL_KEY_STORE_PASSWORD="LAFSHTDBJIWQVHBHSHJD" SERVER_MODE="MASTER" REPORT_SERVER_HOST="localhost"
🌐
LaunchCode
education.launchcode.org › gis-devops › configurations › 02-environment-variables-intellij › index.html
Configuration: Environment Variables - IntelliJ — LaunchCode: GIS DevOps documentation
We wrap the environment variables in curly brackets and start it with a dollar sign. 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
🌐
JetBrains
plugins.jetbrains.com › plugin › 7861-envfile
EnvFile - IntelliJ IDEs Plugin | Marketplace
EnvFile Requires Java 21 GitHub | Issues Env File is a plugin for JetBrains IDEs that allows you to set environment variables for your run configurations from one or...
🌐
JetBrains
jetbrains.com › help › idea › program-arguments-and-environment-variables.html
Program arguments, VM options, environment variables | IntelliJ IDEA Documentation
May 27, 2025 - 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 ...
🌐
Twilio
twilio.com › en-us › blog › set-up-env-variables-intellij-idea-java
Configure Environment Variables in IntelliJ IDEA | Twilio
July 3, 2024 - Save the file and go back to edit ... the environment variables to the newly created class. Select the rectangle icon in the Main class section and select the SMSApp class as seen below: Click on the Apply button then OK once finished. Right click on the SMSApp file in the project directory and find the option to Run SMSApp.main()'. Wait a few seconds for the project to build and compile. When running, the Run window in the IntelliJ IDEA console ...
Find elsewhere
🌐
CodeGenes
codegenes.net › blog › intellij-executing-a-program-with-environment-variables-stored-in-a-separated-file
How to Load Environment Variables from a Separate File in IntelliJ Run Configuration for Executing Programs — codegenes.net
Manually entering variables in IntelliJ’s run settings is error-prone and inefficient—especially when working with multiple variables or environments. In this blog, we’ll walk through a step-by-step guide to loading environment variables from a .env file into IntelliJ’s run configurations.
🌐
GitHub
github.com › ashald › EnvFile
GitHub - ashald/EnvFile: EnvFile 3.x is a plugin for JetBrains IDEs that allows you to set environment variables for your run configurations from one or multiple files. · GitHub
Environment variables are evaluated in the order they are defined in files. Files are evaluated in the order defined in EnvFile UI. Environment variables defined in run configuration can be ordered relatively to files.
Starred by 603 users
Forked by 141 users
Languages   Java
🌐
Baeldung
baeldung.com › home › ide › how to set up environment variables in intellij idea
How to Set Up Environment Variables in IntelliJ IDEA | Baeldung
May 11, 2024 - In the above process, we added the environment variable testUser baeldung into a project in IntelliJ by making changes in the run configuration. We can also add environment variables to a configuration file and link it to a project by editing the run configuration of an application.
🌐
JetBrains
jetbrains.com › help › idea › http-client-variables.html
HTTP Client variables | IntelliJ IDEA Documentation
If files from these directories contain an environment with the same name as an environment from the For File section, it won't be shown in the list. You can give an environment a unique name if you want it to be seen everywhere in your project. Let's illustrate this with an example. Suppose you have the following project structure: root/http-client.env.json # public file with 'dev' environment and 'host' variable root/service1/http-client.private.env.json # private file with 'dev' environment and "key": "myKey1" variable root/service2/http-client.private.env.json # private file with 'dev' environment and "key": "myKey2" variable
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 5333661014674-Load-variables-from-file
Load variables from file – IDEs Support (IntelliJ Platform) | JetBrains
April 29, 2022 - Do you use the environment script in your toolchain `File | Settings | Build, Execution, Deployment | Toolchains` (see https://www.jetbrains.com/help/clion/quick-tutorial-on-configuring-clion-on-windows.html#env-scripts)?
🌐
CodeNote
codenote.net › en › posts › 5883
How to Load Environment Variables from .env File in IntelliJ IDEA
Launch IntelliJ IDEA.app from macOS Terminal with the following command: ... That’s all from the Gemba, where I want to load environment variables from .env files in IntelliJ IDEA.
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.

🌐
Medium
medium.com › @guytheuws › mac-use-environment-variables-in-intellij-6b5772623677
Mac: use environment variables in IntelliJ | by Guy Theuws | Medium
January 18, 2020 - In most situations this is not desirable. In order to fix this we want to use 'real' system environment variables (system wide settings). Let's first append a new environment variable to our .bashrc file: ... Environment variables will still not be picked up by IntelliJ.
🌐
/home/amroz
adammroz.dev › 2020 › 05 › 12 › intellij-and-path-variable.html
[EN] Environment variables in IntelliJ IDEA | /home/amroz
May 12, 2020 - Open File -> Settings -> Build, Execution, Deployments -> Build Tools -> Maven -> Runner -> Environment variables and tick Include system environment variables.
🌐
Reddit
reddit.com › r/intellijidea › environment variable manager plugin
r/IntelliJIDEA on Reddit: Environment Variable Manager Plugin
May 6, 2025 -

Hey everyone!

👋 I recently built a plugin called Environment Variable Manager to help manage environment variable sets directly within IntelliJ IDEA. I made it because I was constantly switching between different configs and got tired of copy-pasting env vars and manually updating into run configurations.

The plugin lets you:

  • Create/edit/clone multiple env var sets

  • Import/export from .env files

  • Easily switch the active set and inject it into your run configs with one click

  • Keep everything persistent across IDE restarts

It’s open source and still pretty new—if you want to give it a try or share feedback, I’d love that. Contributions are also very welcome!

🔗 JetBrains Plugin: https://plugins.jetbrains.com/plugin/27264-environment-variable-manager/

🔗 GitHub: https://github.com/yelynn1/intellij-env-manager

Thanks! 😊

🌐
Apache
cwiki.apache.org › confluence › display › STREAMPIPES › Intellij+env+file+plugin
Intellij env file plugin - STREAMPIPES - Apache Software Foundation
While developing processing elements in IntelliJ several configuration parameters, like default port or host names must be changed. Use a plugin for your IDE to manage all variables in an environment file (e.g.