A minimal yet modular HTTP server in Java built from scratch โ supports:
- ๐งต Thread pool based on available CPU cores
- ๐ Directory listing
- ๐ Graceful shutdown
- ๐ Static file serving (HTML, CSS, JS, images)
- ๐งฑ Modular structure (Server, Handler, Utilities)
- Java 8 or later
- IDE like Eclipse, IntelliJ, or CLI (javac + java)
- Clone this repo or download the source.
- Open Eclipse โ Create New Java Project
- Inside
src/, create a package calledserver - Copy the
.javafiles intosrc/server/ - Create a folder
public/(outsidesrc/) and place anindex.html - Run
SimpleHTTPServer.java - Open http://localhost:8080
SimpleJavaHTTPServer/
- โโโ public/ # Static files to serve โ โโโ index.html
- โโโ src/ โ โโโ server/ โ โโโ SimpleHTTPServer.java โ โโโ ClientHandler.java โ โโโ HTTPUtils.java
- โโโ README.md
| Feature | Description |
|---|---|
| ๐ Thread Pool | Uses Runtime.getRuntime().availableProcessors() for scalable performance |
| ๐ Directory List | Lists folder contents via dynamic HTML |
| ๐งฑ Modular Code | Separated into server, handler, utility classes |
| ๐ Graceful Stop | Shutdown hook handles Ctrl+C or Eclipse stop button cleanly |
| ๐ Static Serving | Serves HTML, CSS, JS, images from public/ folder |
- ๐ Support for POST requests and form submissions
- ๐ Add basic authentication or IP filtering
- ๐ Implement logging (to console or file)
- โ๏ธ Add config file for port, base directory, max threads
- ๐งช Add unit tests for handlers and utility methods
- ๐ฆ Support MIME upload/file download features
- ๐ Enable CORS headers for cross-origin support
๐ฌ Feedback & Contact
Have suggestions, feedback, or want to collaborate?
- ๐ง Email: sanskargunde@gmail.com
- ๐ LinkedIn: www.linkedin.com/in/sanskar-gunde-7b9a0b33a
- ๐ฑ Mobile: +91 8857035293
Feel free to reach out for Java backend projects, internships, open-source collaboration, or tech chats!