22

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 :

-DDATABASE_URL=jdbc:oracle:thin:@dbbdevdb0397.fr:1522:DBZD08

My concern is to add all environment variables in my IntelliJ configuration automatically. That is why I have set these environment variables inside a separated file

Example : DEV.env

DATABASE_URL=jdbc:oracle:thin:@dbbdevdb0397.fr:1522:DBZD08

Is it possible to load this file DEV.env in a IntelliJ run configuration as it could be done by SH script:

eval $(cat DEV.env | sed 's/^/export /');
OlivierTerrien
  • 2,451
  • 1
  • 19
  • 31

1 Answers1

30

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

Angelo
  • 786
  • 8
  • 8
  • in my case the local.env file did not take effect for the environment variable i wanted to use; i had to use "run configuration" -> configuration tab -> Environment filed to fill in – soMuchToLearnAndShare Feb 03 '23 at 15:38
  • 2
    In case it helps anyone, I'm using the latest version of IntellIJ 2023.1 and sadly I couldn't get the plugin to work. However, the exact same steps work for a new plugin called "EnvFile". – waykiki Mar 29 '23 at 12:17