GeoIP2-java icon indicating copy to clipboard operation
GeoIP2-java copied to clipboard

Error when creating databse reader

Open jzapantis opened this issue 11 years ago • 6 comments

I am new to GeoIP and am trying to set up a test app to try it out on the free databases. I have imported the DatabaseReader class as well as the DatabaseReader.Builder class, and when I create a DatabaseReader object the I get an error that says:

Exception in thread "main" java.lang.NoClassDefFoundError: com/maxmind/db/Reader$FileMode at com.maxmind.geoip2.DatabaseReader$Builder.(DatabaseReader.java:76) at GeoIP.main(GeoIP.java:55) Caused by: java.lang.ClassNotFoundException: com.maxmind.db.Reader$FileMode at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 2 more Java Result: 1

I am not sure why this is, I have a File object pointing to my database and have no errors there. And I have properly added the GeoIP2.jar file to my project. Has anyone seen this error before?

untitled

jzapantis avatar Jul 06 '15 01:07 jzapantis

Have you imported the underlying DB reader classes?

2shortplanks avatar Jul 06 '15 14:07 2shortplanks

I am not sure which you are referring too, however here is a screen shot of my imports untitled

jzapantis avatar Jul 06 '15 22:07 jzapantis

I have imported both DatabaseReader and DatabaseReader.Builder classes. Are those what you are referring to?

jzapantis avatar Jul 06 '15 22:07 jzapantis

If you are not using Maven-compatible dependency management, please add all the jar files from the geoip2-*-with-dependencies.zip file on the releases page to your class path.

oschwald avatar Jul 07 '15 02:07 oschwald

If you do want to use Maven dependencies, NetBeans makes it straightforward - once you add geoip2 as a dependency, building the project will pull in everything else that is needed. http://wiki.netbeans.org/QuickStartJavaMavenProject

andyjack avatar Jul 07 '15 14:07 andyjack

I am going to close this. We updated the documentation to make it more clear how to use the JAR files directly without Maven or a compatible tool.

oschwald avatar Jul 17 '15 16:07 oschwald