// tips here // // source: // http://www.maxmind.com/app/java // // compiling jar: // cd source/com/maxmind/geoip // javac *.java // cd ../../../.. (or so) // jar cf maxmindgeoip.jar com/maxmind/geoip/Country.class com/maxmind/geoip/DatabaseInfo.class com/maxmind/geoip/Location.class com/maxmind/geoip/LookupService.class com/maxmind/geoip/Region.class com/maxmind/geoip/regionName.class com/maxmind/geoip/timeZone.class // // database: // http://www.maxmind.com/app/geolitecity // import com.maxmind.geoip.*; LookupService cl; void setup() { loadGeoIP(); CityLookupTest(); } void loadGeoIP() { try { cl = new LookupService(dataPath("GeoLiteCity.dat"), LookupService.GEOIP_INDEX_CACHE); } catch (IOException e) { System.out.println("IO Exception:" + e); } } void CityLookupTest () { try { //Location l1 = cl.getLocation("213.52.50.8"); //Location l2 = cl.getLocation("198.4.104.128"); //Location l2 = cl.getLocation("www.roberttwomey.com"); Location l2 = cl.getLocation("www.washington.edu"); System.out.println("countryCode: " + l2.countryCode + "\n countryName: " + l2.countryName + "\n region: " + l2.region + "\n regionName: " + regionName.regionNameByCode(l2.countryCode, l2.region) + "\n city: " + l2.city + "\n postalCode: " + l2.postalCode + "\n latitude: " + l2.latitude + "\n longitude: " + l2.longitude + // "\n distance: " + l2.distance(l1) + // "\n distance: " + l1.distance(l2) + "\n metro code: " + l2.metro_code + "\n area code: " + l2.area_code + "\n timezone: " + timeZone.timeZoneByCountryAndRegion(l2.countryCode, l2.region)); cl.close(); } catch (Exception e) { System.out.println("Exception: " + e); } }