Java 在哪里可以找到OpenWeatherMap jar?
我想创建java天气应用程序 我有OpenWeather的代码和API,但没有jar文件 这是我的密码Java 在哪里可以找到OpenWeatherMap jar?,java,openweathermap,Java,Openweathermap,我想创建java天气应用程序 我有OpenWeather的代码和API,但没有jar文件 这是我的密码 public class WeatherTest { public static final void main(String[] args) { boolean isMetric = true; String owmApiKey = "XXXXXXXXXXXX"; /* YOUR OWM API KEY HERE */
public class WeatherTest {
public static final void main(String[] args) {
boolean isMetric = true;
String owmApiKey = "XXXXXXXXXXXX";
/* YOUR OWM API KEY HERE */
String weatherCity = "Brisbane,AU";
byte forecastDays = 3;
OpenWeatherMap.Units units = (isMetric)
? OpenWeatherMap.Units.METRIC
: OpenWeatherMap.Units.IMPERIAL;
OpenWeatherMap owm = new OpenWeatherMap(units, owmApiKey);
try {
DailyForecast forecast = owm.dailyForecastByCityName(weatherCity, forecastDays);
System.out.println("Weather for: " + forecast.getCityInstance().getCityName());
int numForecasts = forecast.getForecastCount();
for (int i = 0; i < numForecasts; i++) {
DailyForecast.Forecast dayForecast = forecast.getForecastInstance(i);
DailyForecast.Forecast.Temperature temperature = dayForecast.getTemperatureInstance();
System.out.println("\t" + dayForecast.getDateTime());
System.out.println("\tTemperature: " + temperature.getMinimumTemperature()
+ " to " + temperature.getMaximumTemperature() + "\n");
}
} catch (IOException | JSONException e) {
e.printStackTrace();
}
}
}
公共类天气测试{
公共静态最终void main(字符串[]args){
布尔isMetric=真;
字符串owmApiKey=“xxxxxxxxxxx”;
/*这里是您的OWMAPI密钥*/
字符串weatherCity=“澳大利亚布里斯班”;
字节预测天数=3;
OpenWeatherMap.Units=(isMetric)
?OpenWeatherMap.Units.METRIC
:OpenWeatherMap.Units.IMPERIAL;
OpenWeatherMap owm=新的OpenWeatherMap(单位,owmApiKey);
试一试{
DailyForecast forecast=owm.dailyForecastByCityName(天气城市,预报天数);
System.out.println(“天气预报:”+forecast.getCityInstance().getCityName());
int numForecasts=forecast.getForecastCount();
for(int i=0;i
OpenWeatherMap提供了一个REST API,您可以调用它来获取天气数据。请参考API规范
为了用Java代码调用它,您必须实现RESTJava客户机。有很多方法可以做到这一点,但首先,您可以参考
另外,还有许多围绕OpenWeatherMapAPI开发的客户机。你可以在
既然您正在寻找Java,我建议您看看
此库的一个示例位于您所指的Jar文件是什么。OpenWeatherMap提供了一个REST API,您可以调用它来获取数据?你能帮我吗?