Basically, you want to interpolate String with environment variables and expand your home directories. I don't know an easy way to do the latter, but if you use Spring for your customization, you can use its PropertyPlaceholderConfigurer to replace placeholders in strings.
By default, environment variables are included in a set of replacement replacements.
UPDATE: since this is from the user, you can still use Spring helper classes:
String stringToBeInterpolated = ....;
Properties properties = System.getProperties();
PropertyPlaceholderHelper helper = new PropertyPlaceholderHelper("${","}");
String interpolatedValue = helper.replacePlaceholders(stringToBeInterpolated , properties);
~, , .