Is it possible to know from Java where the computer where it's running is? If not, how can I do it using JNI? Or any scripts? I'm building a Java system, and on login, I'm supposed to register on the database who's logging in, where and when. I just don't know how to get the where.
From Java, how to find out the physical location (city, country) of the computer where it's running?
Asked
Active
Viewed 1,266 times
2
-
Assuming you're using servlets, get the IP and use a region lookup table. (No, you won't get city accuracy with this, but that's as good as you get without the user actually telling you.) – Feb 12 '12 at 14:03
2 Answers
2
Unless you can get the client to send in some sort of coordinates (like GPS), you could use some IP-based solution, such as MaxMind GeoIP. They have a lite
versions of the city and country locating databases, which are free but less accurate. There are APIs available for most common languages.

esaj
- 15,875
- 5
- 38
- 52
1
You could use the ip-address to locate the country where the computer is running. There are several ip address databases available - just look them up in a search machine.

Alex
- 2,106
- 16
- 15