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

finding ip thru a java application

hi guys , i have a query
if some group of people are using the same java application and are connected via LAN . It is like in the java application , i want to expose other people ip address , so that i am able to send message via LAN .
you guys got any idea how shd i code it ?

nccliang
Newbie Poster
6 posts since Jun 2005
Reputation Points: 10
Solved Threads: 0
 

Look up the InetAddress class:

http://java.sun.com/j2se/1.4.2/docs/api/java/net/InetAddress.html

There should be a method in there that suits your needs.

server_crash
Postaholic
2,111 posts since Jun 2004
Reputation Points: 113
Solved Threads: 20
 

here's the method:

try {
          InetAddress inetAdd =
              InetAddress.getByName(input.getText());
          output.setText(inetAdd.getHostAddress());
        }
        catch (Exception e1)
        {
          output.setText("ERROR");
        }
Ghost
Posting Whiz
352 posts since Aug 2004
Reputation Points: 12
Solved Threads: 2
 

Hi everyone,

You can see the below three links. They come with sample codes and examples

http://javaalmanac.com/egs/java.net/GetHostname.html

http://javaalmanac.com/egs/java.net/ResolveHostname.html?l=rel

http://javaalmanac.com/egs/java.net/Local.html?l=rel

I hope this helps you

Richard West

freesoft_2000
Practically a Master Poster
623 posts since Jun 2004
Reputation Points: 25
Solved Threads: 10
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You