- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java program to Get IP address of the system
The InetAddress class This class represents an Internet Protocol (IP) address. You can get the local IP Address & Hostname of the system using getLocalAddress() method of this class
Example
import java.net.InetAddress; public class GetIpAddress { public static void main(String args[]) throws Exception{ InetAddress addr = InetAddress.getLocalHost(); System.out.println("Local HostAddress: "+addr.getHostAddress()); String hostname = addr.getHostName(); System.out.println("Local host name: "+hostname); } }
Output
Local HostAddress: 192.168.25.1 Local host name: Tutorialspoint
- Related Articles
- Java program to find IP Address of the client
- Java program to display Hostname and IP address
- Java program to convert Byte array to IP Address
- How to get the ip address in C#?
- How to get the IP address of android device programmatically?
- C# program to find IP Address of the client
- Python program to find the IP Address of the client
- How to get IP address settings using PowerShell?
- How to get a Docker Container IP address?
- C Program to validate an IP address
- JavaScript program to retrieve clients IP address
- How to get the Android Emulator's IP address?
- How to get the IP Address of local computer using C/C++?
- How to get the IP address of the Android device programmatically using Kotlin?
- Program to display hostname and IP address C

Advertisements