A Java Swing desktop application for emergency situations with one-click SOS alerts via WhatsApp, contact management, secure authentication, and location tracking.
- π One-Click SOS: Send emergency alerts to all saved contacts instantly
- π¬ WhatsApp Integration: Automatic message sending via WhatsApp Desktop/Web
- π Location Tracking: Browser-based geolocation with IP fallback for accurate coordinates
- π₯ Contact Management: Add, edit, and delete emergency contacts with phone validation
- π Secure Authentication: PBKDF2WithHmacSHA256 password hashing with session persistence
- πΎ MySQL Database: Persistent storage for users, contacts, and location history
- π¨ Modern UI: Clean Segoe UI interface with emergency-themed styling
- βοΈ Customizable Settings: Edit default emergency message template and location preferences
- Language: Java 11+
- UI Framework: Swing (javax.swing)
- Database: MySQL 8.0+
- JDBC Driver: MySQL Connector/J 9.4.0
- Security: PBKDF2WithHmacSHA256 password hashing with salted storage
- External APIs:
- WhatsApp Web API (whatsapp:// protocol & web.whatsapp.com)
- IP Geolocation API (ip-api.com)
- Browser Geolocation API (navigator.geolocation)
Before running the application, ensure you have:
- Java JDK 11 or higher - Download here
- MySQL Server 8.0+ - Download here
- WhatsApp Desktop (optional but recommended) - Download here
- A web browser (Chrome, Edge, Firefox) for location permissions
git clone https://github.com/YOUR_USERNAME/emergency-assistance-hub.git
cd emergency-assistance-hubCreate the database and tables using the provided schema:
# Login to MySQL
mysql -u root -p
# Create database
CREATE DATABASE sosdb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
USE sosdb;
# Run schema script
source schema.sql;
# Or on Windows with MySQL command line:
# mysql -u root -p sosdb < schema.sqlCreate a db.properties file in the project root:
db.url=jdbc:mysql://localhost:3306/sosdb?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC
db.user=root
db.password=YOUR_MYSQL_PASSWORDdb.properties to version control (already in .gitignore)
run.bat# Compile
javac -cp ".;mysql-connector-j-9.4.0.jar" -d out *.java
# Run
java -cp ".;out;mysql-connector-j-9.4.0.jar" Main# Compile
javac -cp ".:mysql-connector-j-9.4.0.jar" -d out *.java
# Run
java -cp ".:out:mysql-connector-j-9.4.0.jar" Main-
Launch the application - You'll see a welcome dialog
-
Register with your details:
- Full Name
- ID Type (Aadhar, Driving License, Passport, Ration Card)
- ID Number
- Email (used for login)
- Phone number with country code (e.g., +919876543210)
- Password
- Allow location permission (recommended)
-
Login on subsequent launches with your email and password
- Navigate to the Contacts tab
- Enter contact name and phone number
β οΈ Important: Include country code (e.g., +919876543210, +14155551234)
- Click Add Contact
- Use Edit to modify contact details
- Use Delete to remove contacts
- Navigate to the Emergency tab
- Click the red SOS button
- Confirm the action in the dialog
- The app will:
- Detect your location (browser permission required)
- Open WhatsApp Desktop/Web for each contact
- Pre-fill emergency message with your name and location
- Manually click "Send" in each WhatsApp tab (platform limitation)
- Navigate to the Settings tab
- Edit the default emergency message template
- Use
<name>placeholder to insert your full name - Example:
"Hello, EMERGENCY... I am <name>. I need help... My location:"
- Use
- Toggle auto-location detection
- Click Save Settings
- Password Hashing: PBKDF2WithHmacSHA256 with 65,536 iterations and random salt
- Session Persistence: Encrypted session files for "remember me" functionality
- SQL Injection Protection: Prepared statements for all database queries
- Sensitive Data:
db.propertiesand session files excluded from version control
-
Manual Send Required: WhatsApp blocks automatic message sending for security. You must manually click "Send" for each contact.
-
Location Accuracy:
- Browser geolocation (requires permission) is more accurate
- IP-based fallback may be off by several kilometers
- Not accurate enough for precise emergency services
-
Multiple Tabs: One browser tab opens per contact, which can be overwhelming with many contacts (keep 3-5 key contacts).
-
Desktop Only: This is a desktop app. For real emergency use with automatic SMS and GPS:
- Consider migrating to Android/iOS
- Use native mobile emergency features
-
Phone Format: Phone numbers must include country code (no automatic prepending).
emergency-assistance-hub/
βββ Main.java # Main UI and application logic
βββ ContactManager.java # Contact CRUD operations
βββ ContactModel.java # Contact data model
βββ UserManager.java # Authentication and session management
βββ Database.java # Database connection and queries
βββ PasswordUtil.java # Password hashing utilities
βββ AppStyles.java # UI theme and styling constants
βββ UIComponents.java # Reusable UI components
βββ schema.sql # Database schema
βββ run.bat # Windows run script
βββ run.ps1 # PowerShell run script
βββ mysql-connector-j-9.4.0.jar # JDBC driver
βββ .gitignore # Git ignore rules
βββ LICENSE # MIT License
βββ README.md # This file
- Verify MySQL is running:
mysql -u root -p - Check
db.propertiescredentials - Ensure database
sosdbexists - Check firewall/port 3306 is open
- Install WhatsApp Desktop for better integration
- Check if browser blocks popups
- Verify phone numbers include country code
- Allow browser location permission when prompted
- Check internet connection (IP fallback requires it)
- Try a different browser if geolocation fails
- Verify Java JDK 11+ is installed:
java -version - Ensure
mysql-connector-j-9.4.0.jaris in the project directory - Check classpath separator (
;on Windows,:on Linux/Mac)
Contributions are welcome! Please feel free to:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built as an academic project for emergency assistance
- WhatsApp Web API for messaging integration
- IP Geolocation by ip-api.com
- MySQL for database management
- Java Swing for cross-platform UI
For questions, issues, or suggestions:
- Open an issue in this repository
- Contact: [Your Email]
Made with β€οΈ for safety and emergency preparedness