• 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
  • Liutauras Vilda
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Peter Rooke
  • Himai Minh
Bartenders:
  • Piet Souris
  • Mikalai Zaikin

How to IP address(URGENT)

 
Ranch Hand
Posts: 469
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, I got it!
 
That which doesn't kill us makes us stronger. I think a piece of pie wouldn't kill me. Tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic