Using MaxMind java class with ColdFusion

Viewed 384

I'm trying to use MaxMind java library with ColdFusion.

I start converting this sample code on official MaxMind site:

// A File object pointing to your GeoIP2 or GeoLite2 database
File database = new File("/path/to/GeoIP2-City.mmdb");

// This creates the DatabaseReader object, which should be reused across
// lookups.
DatabaseReader reader = new DatabaseReader.Builder(database).build();

InetAddress ipAddress = InetAddress.getByName("128.101.101.101");

// Replace "city" with the appropriate method for your database, e.g.,
// "country".
CityResponse response = reader.city(ipAddress);

Country country = response.getCountry();

What I've tried is:

var file = "pathto\maxmind\GeoLite2-City.mmdb";
var db = createObject("java","java.io.File").init(file);

var mm = createObject("java", "com.maxmind.geoip2.DatabaseReader")
.Builder(db)
.build();

dump(c);abort;

I got this error:

Type: java.lang.NoSuchMethodException 
Messages: No matching Method for Builder(java.io.File) found 
for com.maxmind.geoip2.DatabaseReader

What I'm doing wrong?

2 Answers
Related