Using environment variables in VM Options and Software Arguments

In my project configuration in IDEA, I have the following text fields:

Project configuration

I would like to define some environment variables and refer to them in the "VM options"and fields "Program arguments".

I tried using the following definitions for environment variables:

MY_FOLDER=/some/random/path
MY_ARGUMENT=2

and then in "VM options"I entered:

- Dfoo=$MY_FOLDER

and in the arguments of the program I introduced

$MY_ARGUMENT foo bar

However, environment variables do not seem to be allowed until my class is called, i.e. if I check args[0]in Java, it contains a string value $MY_ARGUMENT, not 2 .

Why? and how can i fix it?

+4
source share
3

$ENV_VAR $ .

, .

+4

, , . :

VM: -Dfoo=${MY_ENV_VAR}

VM options

MY_ENV_VAR .

: IntelliJ IDEA 2017.1.2 .

+4

- , . ,

java MyMainClass /some/random/path 2

args []

0: /some/random/path
1: 2
0

Source: https://habr.com/ru/post/1525277/


All Articles