954,136 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Finding an IP address using Java (was: do u know?)

How to get IP Address of all PC through java program

adityabakle
Newbie Poster
8 posts since Aug 2004
Reputation Points: 11
Solved Threads: 0
 

what do you mean for example i have a java script on one of my sites that tells the user visiting the site what there ip adress is. or are you trying to find all ur ip info cuz then you dont need a java program just goto run

mikeandike22
Nearly a Posting Virtuoso
1,496 posts since May 2004
Reputation Points: 33
Solved Threads: 19
 

I tell you the way round ...

Process p = Runtime.Runtime().exec("ipconfig");

or just type another command for finding what computers are connected to your computer ( see net commands )

if you have linux or something .... write the commands over ipconfig.

nanosani
Unauthenticated Liar
Team Colleague
1,830 posts since Jul 2004
Reputation Points: 45
Solved Threads: 56
 

The best way to obtain IP address is via the JDK's InetAddress
http://java.sun.com/j2se/1.4.2/docs/api/java/net/InetAddress.html#getLocalHost()

This returns InetAddress which has many goodies you can play around with.

For example, You can do things like reverse domain name loook ups on arbitrary ipaddresses... or ip addresses from hostnames.
http://www.cs.ucl.ac.uk/staff/sjiang/webpage/reverse-lookup-test.htm

By the way Nice Runtime Trick nanosani... it doesn't work if the host is running a secure classloader though... or another OS withouth ipconfig for that matter. =\

cosi
Junior Poster
153 posts since Aug 2004
Reputation Points: 17
Solved Threads: 1
 

How to discover the local area network in java?

divakar.durai
Newbie Poster
1 post since Dec 2009
Reputation Points: 10
Solved Threads: 0
 
How to discover the local area network in java?


By reading above replies and not asking general questions...

peter_budo
Code tags enforcer
Moderator
15,432 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 901
 

How to find the class of an ip address? please provide me a code in java or c++.......

abhinay1111
Newbie Poster
2 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
 
How to find the class of an ip address? please provide me a code in java or c++.......


Please read previous replies and in the future do not ask question in old thread that already have answer to it

If you have more specific questions then demanding code you are more then welcome to create new thread. As of now thread is closed

peter_budo
Code tags enforcer
Moderator
15,432 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 901
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You