How to get computer name in Java

To get computer name in Java you can use the following snippet.

Sample Java

import java.net.*;
System.out.println(InetAddress.getLocalHost().getHostName());

Please Share us:
Please rate this snippet

One thought on “How to get computer name in Java

Leave a Reply