- // netbeans
- // paulogp
- // get local host name and address
- import java.net.InetAddress;
- import java.net.UnknownHostException;
- public class Main {
- public static void main(String[] args) {
- try {
- System.out.println(InetAddress.getLocalHost().getHostName());
- System.out.println(InetAddress.getLocalHost().getHostAddress());
- } catch (UnknownHostException e) {
- System.err.println(e);
- }
- }
- }