private static String replaceEnvVariables(String value){
  Matcher matcher=envPattern.matcher(value);
  if (matcher.find()) {
    String envVar=matcher.group(1);
    return value.substring(0,matcher.start(1) - 2) + System.getenv(envVar) + value.substring(matcher.end(1) + 1);
  }
 else {
    return value;
  }
}

private static String replaceEnvVariables ( String value ) { Matcher matcher = envPattern . matcher ( value ) ; if ( matcher . find ( ) ) { String envVar = matcher . group ( 1 ) ; return value . substring ( 0 , matcher . start ( 1 ) - 2 ) + System . getenv ( envVar ) + value . substring ( matcher . end ( 1 ) + 1 ) ; } else { return value ; } }
replaces environment variables by them actual values using $ { . . . } template .
