Java Console Weather App using OpenWeatherMap
WeatherFetch is a Java console application that fetches live weather data from the OpenWeatherMap API and displays a readable weather report for any city the user enters.
The app was built to practice:
- Calling a real REST API from Java
- Working with JSON using Gson
- Structuring code into clean, testable layers
- Using Maven for dependency management
- Enter any city name (including multi-word cities like
New York,Los Angeles, etc.) - Fetches current weather from OpenWeatherMap:
- City name
- Temperature in Celsius and Fahrenheit
- “Feels like” temperature in both units
- Weather conditions (e.g.,
clear sky,light rain) - Humidity
- Wind speed in mph (converted from m/s)
- Menu-style flow:
- Type city names repeatedly to check multiple locations
- Type
qto quit safely
- Basic error handling for invalid requests
- Language: Java (17+)
- Build tool: Maven
- HTTP client: OkHttp
- JSON parsing: Gson
- Weather API: OpenWeatherMap
git clone https://github.com/AmbrogioBailey/WeatherFetch.git
cd WeatherFetchmacOS / Linux:
export OPENWEATHER_API_KEY="your_real_key_here"Windows PowerShell:
$env:OPENWEATHER_API_KEY="your_real_key_here"IntelliJ:
- Run → Edit Configurations → Environment Variables → Add:
- Name:
OPENWEATHER_API_KEY - Value: your API key
- Name:
IntelliJ: Run Main.java
Maven CLI:
mvn compile exec:java -Dexec.mainClass="com.ambrogioscode.Main"---------- WEATHER REPORT ----------
City: Philadelphia
Temperature: 33°F, 1°C
Feels Like: 21°F, -6°C
Conditions: clear sky
Humidity: 46%
Wind Speed: 18 mph
------------------------------------
- REST API integration using OkHttp
- JSON deserialization using Gson
- Clean separation of concerns
- Secure API key handling via environment variables
- Maven dependency management
- Console UI and control flow
- ANSI color output
- Condition-based emoji icons
- JavaFX GUI version
- ZIP code lookup
- Caching previous search results
- Spring Boot backend version
Free to use for learning, personal, and portfolio purposes.