No way as well. There are number of tricks to collect some data only. There is no set of actions to perform (using any kind of tools) and get complete list of hosts after.
You can get IP by name or name by IP, but you can't even detect is known host online or offline with 100% guarantee.
> I think my question was not formed well. Sorry for
> that.
> I need to have hostnames/ IP addresses of each
> computer connected to a particular LAN.
If i understood your question correctly, you wanted to get list of hosts which are currently connected to your LAN.
In that case (donno whether its correct way) , you can try with
Runtime class and execute "net view" command( in windows).
That should display all computers that are connected in LAN
in command prompt (cmd -windows):
we should redirect the output to one file.
eg : "c:>net view > newFile.txt"
after that we should read the file .
is there any way to redirect the output or (get the output) of cmd to our java program from running process directly?.
> > I think my question was not formed well. Sorry for
> > that.
> > I need to have hostnames/ IP addresses of each
> > computer connected to a particular LAN.
>
> If i understood your question correctly, you wanted
> to get list of hosts which are currently connected to
> your LAN.
> In that case (donno whether its correct way) , you
> can try with
> Runtime class and execute "net view" command( in
> windows).
> That should display all computers that are connected
> in LAN
I believe that shows all windows/samba machines in a domain.
> In that case (donno whether its correct way) , you
> can try with
> Runtime class and execute "net view" command( in
> windows).
> That should display all computers that are connected
> in LAN
But won't that make the code platform specific?
> > In that case (donno whether its correct way) , you
> > can try with
> > Runtime class and execute "net view" command( in
> > windows).
> > That should display all computers that are
> connected
> > in LAN
>
>
> But won't that make the code platform specific?
Yes, your right.
Firstly, directly its not possible in java what you want. But there are other alternates which give you temporary results the one which i suggested. If you want to make it work on any platform, then you should know the relevant commands of all platforms that shows the results and have conditional statements.