tornaia/java-offline-geoip


Java Offline GeoIP maps any IP address to its country code

Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.tornaia:java-offline-geoip:java-offline-geoip-0.1.10'
	}
	dependencies {
		implementation("com.github.tornaia:java-offline-geoip:java-offline-geoip-0.1.10")
	}
	<dependency>
	    <groupId>com.github.tornaia</groupId>
	    <artifactId>java-offline-geoip</artifactId>
	    <version>java-offline-geoip-0.1.10</version>
	</dependency>

                            
    libraryDependencies += "com.github.tornaia" % "java-offline-geoip" % "java-offline-geoip-0.1.10"
        
        

                            
    :dependencies [[com.github.tornaia/java-offline-geoip "java-offline-geoip-0.1.10"]]
        
        

Readme


Java Offline Geoip

GitHub

Donate

Clear feedback. Just if you appreciate my efforts!

Intro

ISO 3166-1 alpha-2 codes are two-letter country codes defined in ISO 3166-1, part of the ISO 3166 standard published by the International Organization for Standardization (ISO), to represent countries, dependent territories, and special areas of geographical interest. Read more

How to use
GeoIP geoIP = GeoIPProvider.getGeoIP();

Optional<String> optionalCountryIsoCode = geoIP.getTwoLetterCountryCode("50.63.202.32");
// optionalCountryIsoCode: Optional[US]

Optional<String> optionalCountryName = geoIP.getCountryName("50.63.202.32");
// optionalCountryName: Optional[United States]
Maven
<dependency>
  <groupId>com.github.tornaia</groupId>
  <artifactId>java-offline-geoip</artifactId>
  <version>0.1.10</version>
</dependency>
Prerequisites for development
  • OpenJDK 8 or later (https://jdk.java.net/)
  • Maven 3.2.1 or later (https://maven.apache.org/download.cgi)
Build
  • mvn clean package
License

The GeoLite2 databases are distributed under the Creative Commons Attribution-ShareAlike 4.0 International License. The attribution requirement may be met by including the following in all advertising and documentation mentioning features of or use of this database:

This product includes GeoLite2 data created by MaxMind, available from <a href="http://www.maxmind.com">http://www.maxmind.com</a>.