Full width home advertisement

Electronics Hub

Internet of Networks

Post Page Advertisement [Top]

Q. Write a Java program in order to check the IP Address of the system.


Ans.

import java.io.*;
import java.net.*;

public class ip
{
public static void main(String args[])
 {
  try
   {
    InetAddress ob=InetAddress.getLocalHost();
    System.out.println("IP of my system:"+ob.getHostAddress());
    }
   catch(IOException e)
   {
    System.out.println("Exception is="+e.getMessage()e.getMessage());
    }
  }
}

Output: 

javac ip.java  (//enter)
java ip  (//enter)
IP of my system: 192.168.1.21


Now check IP Address from Command Prompt

ipconfig
Windows IP Configuration
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix: domain.name
IP Address............................: 192.168.1.21
Subnet Musk.........................: 255.255.255.0
Default Gateway....................: 192.168.1.1


socket programming, socket set
Free image Downloaded from unsplash.com

2 comments:

  1. https://www.earnmoneyonline1.com/2019/03/email-marketing.html

    ReplyDelete
  2. Hi There ,

    Thank you for clearing up my concept on changing IP ADDRESS .


    You are literally awesome! !!. everything is explained in detail
    and easy to understand. Happy Learning! Thanks a lot. Good day man

    Best Regards ,

    www.hellodraweasy.com

    ReplyDelete

Bottom Ad [Post Page]

| Designed by Sriparna Sarkar