on linux command line:
- export DB_SYSTEM=mysql
- echo $DB_SYSTEM
result = mysql - Within Java , i want to access and print value of DB_SYSTEM
could it be:
public Properties getEnvironment() throws java.io.IOException {
Properties env = new Properties();
env.load(Runtime.getRuntime().exec("env").getInputStream());
return env;
}
Properties env = getEnvironment();
String myEnvVar = env.get("DB_SYSTEM");
Just use
System.getenv:If you call it with no arguments, it returns all the environment variables: