This is a simple Java Weather App using JavaFX and an HTML GUI.
It shows weather for predefined cities using a static JSON file.
No API key or internet connection is required, making it ready-to-run for anyone.
- HTML-based GUI inside a JavaFX window.
- Enter a city name to view its weather.
- Works completely offline.
- Easy to run, modify, and extend.
- Learn JavaFX, JSON handling, and HTML integration.
- London
- New York
- Tokyo
- Paris
- Sydney
- Mumbai
- Cairo
- Moscow
Add more cities in
resources/weatherdata.jsonby:
{
"London": { "temp": 18, "description": "Cloudy" },
"New York": { "temp": 25, "description": "Sunny" },
"Tokyo": { "temp": 20, "description": "Rainy" },
"Paris": { "temp": 22, "description": "Sunny" },
"Sydney": { "temp": 15, "description": "Windy" },
"Mumbai": { "temp": 30, "description": "Humid" },
"Cairo": { "temp": 28, "description": "Sunny" },
"Moscow": { "temp": 10, "description": "Snowy" }
\\ Add more cities here in the same way
}
WeatherApp/
│
├── src/
│ ├── Main.java
│ ├── WeatherFetcher.java
│
├── resources/
│ ├── weather.html
│ └── weatherdata.json
│
└── README.md
git clone https://github.com/anshumanjadiya1102/WeatherApp.git
javac --module-path /path/to/javafx/lib --add-modules javafx.controls,javafx.web src/*.javajava --module-path /path/to/javafx/lib --add-modules javafx.controls,javafx.web MainNote
The --module-path tells Java where to find the JavaFX libraries.
JavaFX is not bundled with Java (11+), so you must download it separately from here
Extract the SDK to a folder, for example:
Windows: C:\javafx-sdk-21\lib
Linux/macOS: /home/user/javafx-sdk-21/lib>
Always point the module path to the lib/ folder inside the extracted JavaFX SDK.
+-------------------------------------+
| Weather App |
|-------------------------------------|
| Enter city: [London ] [Get] |
| |
| Temperature: 18°C, Cloudy |
+-------------------------------------+