Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up and using environment variables in IntelliJ Idea

I set up an environment variable (Under IDE Settings -> Path Variables)

 APP_HOME = /path/to/app_home   

One of my tests is failing however with

 System.out.println("APP HOME: " + APP_HOME);  

With

 APP HOME: null/  

It does not look like that env variable is being read. What am i missing?

like image 970
James Leonard Avatar asked Dec 06 '12 17:12

James Leonard


People also ask

How do I use environment variables in IntelliJ?

Click edit configurations on the dropdown box for your runtime configurations. Select the runtime you want to add environment variables to. Click environment variables folder icon to pull up the environment variables screen. From here you can add as many environment variables as you want.

How do I create an ENV file in IntelliJ?

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.


2 Answers

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:

env

like image 177
CrazyCoder Avatar answered Sep 19 '22 13:09

CrazyCoder


If the above answer + restarting the IDE didn't do, try restarting "Jetbrains Toolbox" if you use it, this did it for me

like image 41
sam Avatar answered Sep 17 '22 13:09

sam