How to print the client IP address using java code.

Below is the java source code in order to capture the client ip address. After running this code, you should be able to see the ip address of the machine on which you are running your code.

import java.net.InetAddress;

class IPAddress {
    public static void main(String args[]) throws Exception {
        System.out.println(InetAddress.getLocalHost());
    }
}



No comments:

Post a Comment