Java Program to Get IP Address

« Previous Program Next Program »

Print IP Address

To find/get the IP address in Java Programming, use the method getLocalHost() and display the IP address on the screen as shown in the following program.

Java Programming Code to Get IP Address

Following Java Program get and display the IP Address on the screen:

/* Java Program Example - Get IP Address */
public class JavaProgram
   public static void main(String args[]) throws Exception
      // prints the IP address of your Computer

When the above Java Program is compile and executed, it will produce the following output:

Java Program to get ip address

Same Program in Other Languages

You may also like to learn and practice the same program in other popular programming languages:

Java Online Test

« Previous Program Next Program »

© Copyright 2021. All Rights Reserved.