Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

My IP address

 
Dave Jones
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I'm writing a program and I need to get my IP address (i.e 12.34.123.123 )
I tryed using this code,

but I get:
127.0.0.1 as my address.....not very helpful eh ?...
does someone have a short code sample that will give me what I need ??
Thanks
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're getting exactly what you're asking for, the local host which is always 127.0.0.1
 
Dave Jones
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know, but I need the real ip address not 127.0.0.1 !!
never mind, I got it already.
thanks anyway :roll:
 
Grishma Dube
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
u got it???

tell me how??? even i need to know it
 
Abhishek Roy
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This may helpful

Run as (for IPv4)$java lookupAndReturn abhiroy.com
OR as (for IPv6)$java -6 lookupAndReturn abhiroy.com


[ March 17, 2005: Message edited by: Abhishek Roy ]
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!