Some Java codes that are once in a while needed.