The WeatherAppProject is a Java-based application that provides weather information, including the current weather and a multi-day forecast. It retrieves data from the OpenWeather API and allows users to view temperature, humidity, wind speed, and weather descriptions. The application features a graphical user interface (GUI) implemented with Swing, allowing for an intuitive and user-friendly experience.
- Current Weather and Forecast: Fetches real-time weather data and forecasts for a specified number of days.
- Unit Preferences: Allows users to switch between metric (ยฐC, m/s) and imperial (ยฐF, mph) units.
- Notifications: Provides alerts for high and low temperatures based on user-selected thresholds.
- Persistence: Saves user preferences (units and notifications) in a
userPreferences.propertiesfile, so they persist across sessions.
- Java JDK: Ensure Java Development Kit (JDK) is installed (version 8 or higher).
- Gson Library: The
gson-2.11.0.jarfile should be in thelibdirectory.
To compile the code, open a terminal or command prompt, navigate to the project directory (WeatherAppProject), and run the following command based on your operating system.
javac -cp "lib\gson-2.11.0.jar" -d bin src\*.javajavac -cp "lib/gson-2.11.0.jar" -d bin src/*.javaThis command compiles all .java files in the src folder and places the generated .class files in the bin folder.
After compilation, you can run the WeatherSwingApp class from the bin directory, which serves as the entry point.
java -cp "bin;lib\gson-2.11.0.jar" WeatherSwingAppjava -cp "bin:lib/gson-2.11.0.jar" WeatherSwingAppThis command launches the application with a graphical interface.
- Current Weather: Use the GUI to enter the city name and view current weather details.
- Weather Forecast: Specify the city and number of days for forecast data through the interface.
- Preferences: Update unit preferences (metric or imperial) and enable/disable notifications for high/low temperature alerts via the settings menu.
- The
userPreferences.propertiesfile in theresourcesfolder saves the userโs preferences for units and notifications. - Ensure to set your API key in the
WeatherAPIManagerclass if you replace the code or API credentials.
- If you encounter compilation errors, ensure that the
gson-2.11.0.jarfile is in thelibfolder and that thebinfolder exists. - Make sure to use the appropriate path separators (
;for Windows,:for Linux/macOS) when specifying the classpath.