472,780 Members | 1,372 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,780 software developers and data experts.

How can I find the IP address of the local PC ?

Hi,

Probably an easy answer to this, but I have not been able to figure it out.

How can I find the IP-address of the machine that my Java-program is running
on ? Could not find any methods in the InetAddress class that does this. The
closest I got was the getLocalHost() which will return the IP-address
representing the loopback address (usually 127.0.01, isn't it ?).

Any ideas ?

Regards
Arne
Jul 18 '05 #1
4 27168
Quoth "Arne" <ar**@styve.org>:
Hi,

Probably an easy answer to this, but I have not been able to figure it out.

How can I find the IP-address of the machine that my Java-program is running
on ? Could not find any methods in the InetAddress class that does this. The
closest I got was the getLocalHost() which will return the IP-address
representing the loopback address (usually 127.0.01, isn't it ?).

Any ideas ?


There can be no easy answer to this, because there is no guarantee
that there is a unique answer to this.

After all, if there are two NICs connected to the machine, which is
eminently common for the sorts of "server class" systems you might
deploy Java apps on, there will therefore be TWO answers for it to
find, neither preferable.

We have some Dell servers that came to us with no less than 5 NICs.

You are probably trying to solve some problem the wrong way...
--
wm(X,Y):-write(X),write('@'),write(Y). wm('cbbrowne','cbbrowne.com').
http://cbbrowne.com/info/x.html
"The most precisely-explained and voluminously-documented user
interface "rule" can and will be shot to pieces with the introduction
of a single new priority consideration." -- Michael Peck
Jul 18 '05 #2
Look at java.net.NetworkInterface class.

"Arne" <ar**@styve.org> wrote in message news:426c12a2$1@proxy....
Hi,

Probably an easy answer to this, but I have not been able to figure it out.
How can I find the IP-address of the machine that my Java-program is running on ? Could not find any methods in the InetAddress class that does this. The closest I got was the getLocalHost() which will return the IP-address
representing the loopback address (usually 127.0.01, isn't it ?).

Any ideas ?

Regards
Arne

Jul 18 '05 #3
Hi Christopher,

Thanks for your reply. I am aware of that one machine can have many
IP-addresses, hence I would be happy if I could get to the list of
IP-addresses, or alternatively the MAC-addresses. Or a third alternative
would be to get the networkname of the computer.

The problem I'm trying to solve is related to a framwork I've created for
remote startup of processes/applications. I have one server PC, which
controlles a number of client PCs. The clients registeres at the server as
soon as the client PC is up running. Depending on the client, the server
assigns a set of processes/applications that the client should be able to
start locally on the client (like Word, Excel, Notpad, or any other SW). All
of this is currently working just fine (using RMI), but in order to make the
client SW as general as possible (I don't want to supply startup arguments
that are special for each client), I was thinking of making it possible for
the client SW to be identical on all clients, but when the client SW starts,
it should read an XML-file common to the entire system, which would specify
(based on some unique ID of the client PC, like one IP address, or a MAC
address or the name of the computer) which processes should be possible to
start on this client PC, and also when, in a larger startup sequence, that
client should start it's process(es).

Hence I think I am stilling trying to solve the overall problem the rigth
way. So if you know how to get to the IP-adress(es) of the PC from Java, I
would be really greatfull.

Arne
"Christopher Browne" <cb******@acm.org> wrote in message
news:BQ******************@news20.bellglobal.com...
Quoth "Arne" <ar**@styve.org>:
Hi,

Probably an easy answer to this, but I have not been able to figure it out.
How can I find the IP-address of the machine that my Java-program is running on ? Could not find any methods in the InetAddress class that does this. The closest I got was the getLocalHost() which will return the IP-address
representing the loopback address (usually 127.0.01, isn't it ?).

Any ideas ?


There can be no easy answer to this, because there is no guarantee
that there is a unique answer to this.

After all, if there are two NICs connected to the machine, which is
eminently common for the sorts of "server class" systems you might
deploy Java apps on, there will therefore be TWO answers for it to
find, neither preferable.

We have some Dell servers that came to us with no less than 5 NICs.

You are probably trying to solve some problem the wrong way...
--
wm(X,Y):-write(X),write('@'),write(Y). wm('cbbrowne','cbbrowne.com').
http://cbbrowne.com/info/x.html
"The most precisely-explained and voluminously-documented user
interface "rule" can and will be shot to pieces with the introduction
of a single new priority consideration." -- Michael Peck

Jul 18 '05 #4
Starting in JDK 1.4 you can use NetworkInterface to enumerate all IP addresses
on your server.

Arne wrote:
Hi,

Probably an easy answer to this, but I have not been able to figure it out.

How can I find the IP-address of the machine that my Java-program is running
on ? Could not find any methods in the InetAddress class that does this. The
closest I got was the getLocalHost() which will return the IP-address
representing the loopback address (usually 127.0.01, isn't it ?).

Any ideas ?

Regards
Arne

Dec 5 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: SB | last post by:
I have a struct with a fixed array of items (see below). How can I obtain the physical address of the array? I don't need to do anything with it other than display it to the end user (this is a...
12
by: Souljaz | last post by:
Hi, how to find IP address. Thanks
23
by: Timothy Madden | last post by:
Hello all. I program C++ since a lot of time now and I still don't know this simple thing: what's the problem with local functions so they are not part of C++ ? There surely are many people...
4
by: SJ | last post by:
How can I find the local Machine's MAC address using asp.net? Thanks, -SJ
3
by: rrs.matrix | last post by:
hi is there any system call in unix that will search for a file in the filesystem. someting like the find utility. if not then how should i search for a file in the file system. heard of...
4
by: toton | last post by:
Hi, How to find address of a class from inside? My class having a overloaded new & delete. new allocates the memory like void* operator new(std::size_t size) throw(){ cout<<"op new...
6
by: Robert E. Cooke | last post by:
Any suggestion on how to locate someone in Houston, Texas highly experienced in Microsoft Access database design?
1
by: princessjewel62 | last post by:
I would like to ask anyone out there, where can I find the "Local Internet Zone" as I had a problem with my application not displaying and saying that I have no authorisation to view this web page...
1
by: Eyalbiber | last post by:
Hi, I've just installed sql server 2005 on my cpu i think it's the enterprise edition and i have few problems : 1.i can't find my local server anywhere(this is my main problem) b.t.w : i'm...
6
by: paal.andreassen | last post by:
I have a problem. I have two instances of a client-server application running on two different machines A and B. A has a listening service, that listens for connections from B B has a listening...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.