Removed java 7 specific stuff and fixed issue when ~ is used in the target path