A simple Java console app that fetches and displays the current weather of a given city using the WeatherAPI.
- Takes city name as input
- Fetches real-time weather data using HTTP requests
- Parses and displays:
- City and country
- Local date
- Temperature (°C / °F)
- Weather condition
- Loops until you type
exit
- Java 17+
- Maven
- WeatherAPI
- Jackson (for JSON parsing)
- Java installed
- Maven installed
- WeatherAPI key (free to get from weatherapi.com)
- Clone the repo:
git clone https://github.com/your-username/weather-app.git cd weather-app
- Add your API Key to the
API_Key
variable in the code. - Run the app:
mvn compile mvn exec:java
If the user types an invalid city, the app currently may crash.
To fix this, you can check the status code or catch the JSON exception and show a friendly message.
This project is open source and free to use.