• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Getting IP Address

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 32
Hibernate Spring Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 68
Netbeans IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Netbeans IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Farmers know to never drive a tractor near a honey locust tree. But a tiny ad is okay:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic