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());
    }
}



1 comment:

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here.
    Kindly keep blogging. If anyone wants to become a Java developer learn from Java EE Online Training from India.
    or learn thru Java EE Online Training from India . Nowadays Java has tons of job opportunities on various vertical industry.

    ReplyDelete