Skip to content

A high-performance, lightweight Java Web Application Server powered by Virtual Threads. πŸš€

License

Notifications You must be signed in to change notification settings

krkarma777/Javelin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

70 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

logo

Javelin WAS - A High-Performance Virtual Thread-Based Web Application Server πŸš€

Javelin WAS is a lightweight, high-performance web application server built on Java Virtual Threads.
It aims to provide a modern alternative to traditional Java-based WAS solutions like Tomcat and Jetty, leveraging Virtual Threads for maximum concurrency and efficiency.


πŸ”₯ Features

  • Virtual Thread-Based Concurrency – Handles thousands of concurrent requests efficiently without blocking OS threads.
  • Lightweight & Fast – Designed to be minimal and optimized for high performance.
  • Easy Routing – Supports simple and flexible request handling.
  • Middleware System – Easily extendable with logging, authentication, and security middleware.
  • JSON Support – Built-in JSON serialization and deserialization.
  • Static File Serving – Serves static files efficiently without external dependencies.
  • Designed for Modern Java Applications – No heavy frameworks required.

β˜• Requirements

  • Java 21 or higher (required for Virtual Threads)
  • Gradle 7+

πŸ› οΈ Installation & Running

1. Clone the repository

git clone https://github.com/your-repo/Javelin.git
cd javelin-was

2. Build & Run (Using Gradle)

./gradlew run

πŸš€ Test the Server

Once the server is running, open your browser or use curl:

curl http://localhost:8080

βœ… Expected Response:

Hello from Javelin Virtual Thread WAS!

βœ… Example Code (Minimal)

public class Main {
    public static void main(String[] args) {
        VirtualThreadServer server = new VirtualThreadServer(8080);

        server.get("/", ctx -> ctx.send("Hello from Javelin Virtual Thread WAS!"));

        server.start();
    }
}

πŸ§ͺ Example Usage

🧩 Middleware

server.use(ctx -> {
    System.out.println("Request Path: " + ctx.path());
    ctx.next();
});

πŸ“¦ JSON Handling

server.post("/echo", ctx -> {
    Map<String, Object> data = ctx.body(Map.class);
    ctx.json(Map.of("you_sent", data));
});

πŸ“ Serving Static Files

To serve files from a public/ directory under /static:

server.use(new StaticFileHandler("/static", "public"));

Then access:

http://localhost:8080/static/index.html

🧠 How It Works

Javelin WAS uses Java 21+ Virtual Threads to efficiently handle HTTP requests without the overhead of traditional thread pools.
Each request is processed in a lightweight Virtual Thread, allowing massive concurrency with minimal resource usage.


πŸ“œ License

This project is licensed under the Apache License 2.0.
See the LICENSE file for more details.


πŸ‘₯ Contributing

We welcome contributions!
Feel free to submit issues, feature requests, or pull requests.


πŸ“§ Contact

For inquiries or collaboration:
πŸ“© krkarma777@gmail.com


Releases

No releases published

Packages

No packages published