Use java API to obtain hostname.