Sachi-17
Sachi-17

Reputation: 529

How to Get The Location Of IP Address through an Standalone Java Class Using Google API?

I need some help regarding the Google Geo location.

My requirement is to write an standalone Java class to get the IP Address and the location of this IP using google API.

I mean I need to send this IP address to the google and get the location.

Can anyone please give some suggestion How can I achieve ?

Note: I dont want to use maxmind api. Is there any other open API through which I can achieve this.

Please give some idea, how to figure it out.

Upvotes: 0

Views: 3513

Answers (1)

m.aibin
m.aibin

Reputation: 3603

Normally, you can use following to get the client’s IP address that’s accessing your Java web application.

String ipAddress = request.getRemoteAddr();

If the client will use proxy, you better use solution from here: Get client ip from HttpServer

You can find a lot of other resources how to do it in Java (for example using sockets).

For geolocating IP address you can use for example this API: http://freegeoip.net/

Upvotes: 1

Related Questions