• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

How to IP address(URGENT)

 
Ranch Hand
Posts: 469
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have stand alone application running on the server. I want to get IP address of server(that's localhost IP address).
Angela
P.S.:I DON'T WANT TO GET LOCAL HOST NAME. I WANT TO GET LOCAL IP ADDRESS(Format : xx.xx.xx.xx)
 
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you have win95 or win98 write this on the run method or in dos: winipcfg
if you have win 2000 or me or nt or xp use this line instead: ipconfig
 
Roy Ben Ami
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oops. did you mean by API ?
then you need to get first the InetAddress of the ServerSocket by using the method getInetAddress().
the use this method of the InetAddress: getHostAddress() which return the String you want.
or you can use this too:
InetAddress address=InetAddress.getLocalHost();
String ip=address.getHostAddress();
[ March 07, 2002: Message edited by: Roy Ben Ami ]
 
Angela D'souza
Ranch Hand
Posts: 469
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Roy Ben Ami:
if you have win95 or win98 write this on the run method or in dos: winipcfg
if you have win 2000 or me or nt or xp use this line instead: ipconfig


HOW TO USE THIS COMMANDS IN JAVA APPLICATION.CAN YOU GIVE ME SMALL EXAMPLE?
Thanks a lot,
Angela
 
Roy Ben Ami
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
excuse me for the first example. i misunderstood you.
look at my second post which is correct.
use these lines to get the IP address and print it:
InetAddress address=InetAddress.getLocalHost();
String ip=address.getHostAddress();
System.out.println(ip);
[ March 07, 2002: Message edited by: Roy Ben Ami ]
 
Angela D'souza
Ranch Hand
Posts: 469
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, I got it!
 
I need a new interior decorator. This tiny ad just painted every room in my house purple.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!