Skip to content

Simple Java Weather App with HTML GUI, fully offline and no API key required. Enter a city name to see static weather info from a JSON file. Great for learning JavaFX, HTML integration, and JSON handling.

Notifications You must be signed in to change notification settings

anshumanjadiya1102/WeatherApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🌤️ Java Weather App (Offline, No API Key Required)

Java Version License GitHub Repo Size Stars


Overview

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.


Features

  • 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.

Supported Cities

  • London
  • New York
  • Tokyo
  • Paris
  • Sydney
  • Mumbai
  • Cairo
  • Moscow

Add more cities in resources/weatherdata.json by:

{
  "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
}

Project Structure

WeatherApp/

├── src/
│ ├── Main.java
│ ├── WeatherFetcher.java

├── resources/
│ ├── weather.html
│ └── weatherdata.json

└── README.md


How to Run

Copy the Code

git clone https://github.com/anshumanjadiya1102/WeatherApp.git

1. Compile

javac --module-path /path/to/javafx/lib --add-modules javafx.controls,javafx.web src/*.java

Run

java --module-path /path/to/javafx/lib --add-modules javafx.controls,javafx.web Main

Note

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.

Output of hardwork

+-------------------------------------+
|           Weather App                |
|-------------------------------------|
| Enter city: [London      ] [Get]    |
|                                     |
| Temperature: 18°C, Cloudy           |
+-------------------------------------+

About

Simple Java Weather App with HTML GUI, fully offline and no API key required. Enter a city name to see static weather info from a JSON file. Great for learning JavaFX, HTML integration, and JSON handling.

Topics

Resources

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published