Maven java.exec environment variable is picked up by maven, but not picked up by the class

550 views Asked by At

I added this maven job.

exec:java -Dexec.mainClass="com.someclass.SomeClass" -DAPP_HOME="${DEV_ENV_LOC}"

What happens is, spring context is able to pickup the value of APP_HOME, but the java class System.getEnv("APP_HOME"), is not able to pick up the value.

Any ideas?

1

There are 1 answers

1
Vitalii Elenhaupt On

For command line options you have to use System.getProperty():

String appHome = System.getProperty("APP_HOME");

Or pass APP_HOME variable as an environment variable with EnvInject Plugin and lookup it with System.getenv():

String appHome = System.getenv("APP_HOME");

Find more details in difference here.