Using environment variables in “VM options” and “Program arguments”

前端 未结 3 753
北海茫月
北海茫月 2020-12-11 01:02

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

\"Project

I woul

相关标签:
3条回答
  • 2020-12-11 01:16

    $ENV_VAR$ will be resolved correctly.

    Idea uses its own notation for environment variables, they should be denoted with two dollar signs on both sides.

    0 讨论(0)
  • 2020-12-11 01:18

    You can access environment variables using the brace-enclosed environment variable syntax. Example:

    VM options: -Dfoo=${MY_ENV_VAR}

    MY_ENV_VAR environment variable will be expanded properly.

    Update: tested in IntelliJ IDEA 2017.1.2 and still working.

    0 讨论(0)
  • 2020-12-11 01:21

    Environment variables are not the same thing as program arguments. If you want to pass program arguments then you would call

    java MyMainClass /some/random/path 2
    

    Then args[] would contain

    0: /some/random/path
    1: 2
    
    0 讨论(0)
提交回复
热议问题