Question

I set an Environment Variable from a .sh file for example

export JBOSS_HOME=/Applications/EAP-6.2.0/jboss-eap-6.2

Now in my Java application if I need to get this JBOSS_HOME I will write

String jbossHome = System.getProperty("JBOSS_HOME");

This works fine when I run the code on the windows machine. It does not give the value for JBOSS_HOME on Mac machine. How can I retrive JBOSS_HOME value on Mac OS machine?

Was it helpful?

Solution

Environments are retrieved via:

System.getenv(name);

Not with System.getProperty().

Use System.getenv() without paramters to get the map of all environment variables.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top