Expand my Community achievements bar.

How to include an external file when compiling

Avatar

Level 3

I've created a servlet and I'm trying to include a Maxmind Geolite database in my application. I've been using a relative path when working on the project, similar to:

File dbfile = new File("C:\Development\Maxmind GeoIP2 DB\GeoLite2-Country.mmdb");DatabaseReader dbReader = new DatabaseReader.Builder(dbfile).build();

This works well on my local computer however I can't seem to figure out how to include the mmdb file when compiling to an application. I've tried using

InputStream dbfile = GeoLocationFilter.class.getResourceAsStream("GeoLite2-Country.mmd");
DatabaseReader dbReader = new DatabaseReader.Builder(dbfile).build();

Any ideas on what I can do?

I'm trying to include a Maxmind database in my application. I've been using a relative path when working on the project, similar to:

0 Replies