aspose file tools*
The moose likes Java in General and the fly likes Get user's location from IP address Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Get user Watch "Get user New topic
Author

Get user's location from IP address

Kevin Zhang
Greenhorn

Joined: Dec 09, 2008
Posts: 6
Hi, there

I'm developing a location based service app. One function is to provide local information based on user's current area.

My question is :

How to get user's location with user's IP address? Any Java APIs ?


Kevin Z
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
You're in luck - an article in the JavaRanch Journal covered this.


Ping & DNS - my free Android networking tools app
Kevin Zhang
Greenhorn

Joined: Dec 09, 2008
Posts: 6
Ulf Dittmer wrote:You're in luck - an article in the JavaRanch Journal covered this.


Thanks, Ulf

I found the free solution is like "IP to country". What I really want is "IP to city".

For example, I want to tell the user is from NY according to his/her IP address.

BTW, Is there any vendor solution for this issue?

kevin

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10451
    
    8

Kevin Zhang wrote:
BTW, Is there any vendor solution for this issue?


Check out http://www.ip2location.com.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39436
    
  28
Maneesh Godbole wrote:
Kevin Zhang wrote:
BTW, Is there any vendor solution for this issue?


Check out http://www.ip2location.com.
It's only got my location wrong by 200 miles!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19722
    
  20

It's got my location wrong by an hour drive. Well, at least it got the country right


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Steve Fahlbusch
Bartender

Joined: Sep 18, 2000
Posts: 571
    
    7

mine was only 326 miles away.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18669
    
    8

When I tried one of those databases it got my country right, but it was still three time zones and around 5,000 kilometres off.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42289
    
  64
The city was correct for me.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39436
    
  28
Mine varies; sometimes it is only 100 miles out. Always in the same general direction, so far.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

You want accuracy, you have to use the pay services. The free databases simply aren't as good.


[Jess in Action][AskingGoodQuestions]
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Even the pay services have limits. Especially in corporate environments. I worked at a company with offices in Dusseldorf Germany that had IP addresses (and networking) from the US. using the IP would have you be off by five or six time zones and an eight hour flight.

Its like phone numbers. In the olden days, you could use the area code and exchange to identify North American phone numbers to within 10 miles. Now, people keep their cell phone numbers, and you can't tell anything. Perhaps you can tell country or continent, but you can't tell much else.
priya uma
Greenhorn

Joined: Aug 10, 2012
Posts: 4
Hi visit http://www.ip-details.com/ip-search/ here if you give the Ip address you can get the details about the location of that particular IP address like the country name ,ip location address,Latitude, Longitude etc...
i hope it will be helpful to you..........
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

priya uma wrote:Hi visit http://www.ip-details.com/ip-search/ here if you give the Ip address you can get the details about the location of that particular IP address like the country name ,ip location address,Latitude, Longitude etc...
i hope it will be helpful to you..........


Being from NYC, most IP locators seems to get it right. I guess cities, especially famous ones, get the data online first. So far, the bad ones report the location as New York City. And the good ones get it closer to the borough of Queens, locating to either Jamaica or Richmond Hill, which I guess, is close enough (only a few miles off).

This one however, put my location as Herndon Virginia, to the exact address of the headquarters of my cable provider. This address is more than 250 miles away, definitely not in New York City, definitely not in New York State, but got the country right.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Henry Wong wrote:put my location as Herndon Virginia, to the exact address of the headquarters of my cable provider.


And without knowing which is your provider, I can be sure that its not really in Herndon VA either. Herndon was a small farming market town when I was a kid. There are office buildings with many corporate HQ there now, but its really just the only post office on the 10+ lane freeway out to Dulles Airport.

Most of the big Internet companies are actually between Herndon and the airport. There is no real name, because in 2000, it was just farmland. That is where AOL built their huge headquarters and where MCI built a monster datacenter. Its also where Equinix has its series of monster co-lo facilities, which host servers for minor companies like Amazon, Yahoo, etc. Sometimes this area is labeled as "Ashburn" but its really nameless.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Get user's location from IP address