• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting IP Address

 
selva nayagam.K
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Pankaj Kr. Singh
Ranch Hand
Posts: 32
Hibernate Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 68
Firefox Browser Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 32
Hibernate Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 68
Firefox Browser Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic