aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes Getting IP Address Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Getting IP Address" Watch "Getting IP Address" New topic
Author

Getting IP Address

selva nayagam.K
Greenhorn

Joined: Nov 16, 2009
Posts: 25
When system is connected to internet I could get the IP address of my system. If is is not connected to the internet, it just returns IP as 127.0.0.1. I would like to get the IP address of the system even if it is not connected to internet. Can anyone help to solve this problem? Thank in advance.

Regards,
Selva.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4664
    
    5

Nothing to do with Swing / AWT / SWT / JFace. I suspect it doesn't belong here either, but if so, I hope another moderator will move it to a better place.

Systems don't have IP addresses, network adapters do.


luck, db
There are no new questions, but there may be new answers.
Pankaj Kr. Singh
Ranch Hand

Joined: Mar 31, 2011
Posts: 32

Hi selva nayagam.K

when system is connected with the network then it is assigned to the IP address if it is not connected to the network then it is recognized as localhost i.e. 127.0.0.1.
Philip Grove
Ranch Hand

Joined: Aug 18, 2009
Posts: 68

Pankaj Singh Hari Om wrote:Hi selva nayagam.K

when system is connected with the network then it is assigned to the IP address if it is not connected to the network then it is recognized as localhost i.e. 127.0.0.1.


Close but not the full truth. If it's a static IP then the computer has a record of the IP address regardless of being connected to a network or not. In the end this is not really a Java issue since you can't get the IP address when the computer doesn't have one.
Pankaj Kr. Singh
Ranch Hand

Joined: Mar 31, 2011
Posts: 32

Hi Philip Grove,
Yes you are right but i think if system is not connect to the network then using java we can't get the ip(static/dynamic) address.
If is there any way to get the Ip when system is offline please Reply.
Thanks .
Philip Grove
Ranch Hand

Joined: Aug 18, 2009
Posts: 68

Pankaj Singh Hari Om wrote:Hi Philip Grove,
Yes you are right but i think if system is not connect to the network then using java we can't get the ip(static/dynamic) address.
If is there any way to get the Ip when system is offline please Reply.
Thanks .


Yes and no. If it's a dynamic IP then the system doesn't have one and you can't get any information, if it's static you should get it as the query in Java gets forwarded to the OS and the OS know it. If the InetAddress doesn't contain anything other than 127.0.0.1 you are not going to get anything else.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting IP Address