This a an easy to use java client for the Openweathermap API
- provide the current temperature at a given city
- Download or clone the repository and build the jar using
mvn clean install
- Import the jar into your own project
- Add the following repository definition to your pom.xml:
<repositories>
<repository>
<id>sonatype-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
- Add the dependency to your pom.xml:
<dependency>
<groupId>com.github.eddykaya</groupId>
<artifactId>openweathermapclient</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
The main class to use is OpenWeatherClient
which provides the following methods:
public Optional<CurrentWeather> fetchCurrentWeatherAt(String city, Locale country)
package de.eddykaya.openweather.client;
import java.util.Locale;
import java.util.Optional;
import de.eddykaya.openweather.entities.external.CurrentWeather;
public class Main {
public static void main(String[] args) {
OpenWeatherClient client = new OpenWeatherClient(""); // provide your API key here
Optional<CurrentWeather> currentWeather = client.fetchCurrentWeatherAt("Stuttgart", Locale.GERMANY);
System.out.println(currentWeather.get());
}
}