code: public static String substituteWithEnvironment(String string0) throws SubstitutionException {
          // turn environment into properties
          Properties envProps = new Properties();
          // add all system environment vars to the properties
          envProps.putAll(System.getenv());
          // delegate to other method using the default syntax $ENV{<key>}
          return substituteWithProperties(string0, "$ENV{", "}", envProps);
      }
docs: Searches the string for occurrences of the pattern $ENV{key} and
  attempts to replace this pattern with a value from the System environment
  obtained using the 'key'.  For example, including "$ENV{USERNAME}" in
  a string and calling this method would then attempt to replace the entire
  pattern with the value of the environment variable "USERNAME". The System
  environment is obtained in Java with a call to System.getenv().  An environment variable is typically
  defined in the Linux shell or Windows property tabs.  NOTE: A Java System
  property is not the same as an environment variable.
  @param string0 The string to perform substitution on such as "Hello $ENV{USERNAME}".
  This string may be null, empty, or contain one or more substitutions.
  @return A string with all occurrences of keys substituted with their
  values obtained from the System environment.  Can be null if the
  original string was null.
  @throws SubstitutionException Thrown if a starting string was found, but the
  ending string was not.  Also, thrown if a key value was empty such
  as using "$ENV{}".  Finally, thrown if the property key was not
  found in the properties object (could not be replaced).
  @see #substituteWithProperties(java.lang.String, java.lang.String, java.lang.String, java.util.Properties)