ActiveJ | Getting Started


ActiveJ is a minimalistic and boilerplate-free Java platform that is intended to replace Spring, Spark, Micronaut, and other similar solutions. It features a rich stack of technologies with an efficient async programming model and powerful DI library ActiveInject.

ActiveJ consists of several loosely coupled components that complement and empower each other: async core, efficient I/O processing, high-performance Jetty and Netty alternatives, along with handy boot utilities.

In this tutorial we will create a simple HTTP server that sends a “Hello World!” greeting. With ActiveJ Launchers, particularly HttpServerLauncher subclass, and ActiveInject DI you can write a fully-functional server in around 10 lines of code.

What you will need:

Which ActiveJ technologies will be used:

To proceed with this guide you have three options:

Create from Maven Archetype

Simply enter the following command in the terminal:

mvn archetype:generate -DarchetypeGroupId=io.activej -DarchetypeArtifactId=archetype-http -DarchetypeVersion=4.0-beta1

The project will be automatically generated on your machine. Open WebApp and run its main method. Then open your favourite browser and go to localhost:8080.

Working Example

Clone ActiveJ locally and import it as a Maven project. Check out branch v4.0-beta1. Before running the example, build the project (Ctrl + F9 for IntelliJ IDEA).

Then open HttpHelloWorldExample class, which is located at activej -> examples -> tutorials -> getting-started and run its main method. Open your favourite browser and go to localhost:8080.

Step-by-step guide

1. Configure the project

First, create a folder for application and build an appropriate project structure:

└── pom.xml
└── src
    └── main
        └── java

Next, you need to integrate ActiveJ in your project. There are two ways to do it. The first option is to add Maven dependency to your project. Simply configure your pom.xml file in the following way:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="" xmlns:xsi="" xsi:schemaLocation="">


  <name>Tutorials : Getting-Started</name>




The second option is to clone ActiveJ from GitHub, import it as a Maven project, check out branch v4.0-beta1 and run the following script in project directory:


Next, configure your pom.xml file like in the example above. Make sure that your project SDK is set to 1.8+.

2. Write HttpHelloWorldExample class

After you integrate ActiveJ in your project in one of the suggested ways, write down the following code to

public final class HttpHelloWorldExample extends HttpServerLauncher {
	AsyncServlet servlet() {
		return request -> HttpResponse.ok200().withPlainText("Hello World");

	public static void main(String[] args) throws Exception {
		Launcher launcher = new HttpHelloWorldExample();

First, we extend HttpHelloWorldExample from HttpServerLauncher to manage application lifecycle. In this example, the only important thing to know about the superclass is that it implements the launch method that starts our server.

Next, we provide an AsyncServlet which receives HttpRequests from clients, creates HttpResponses and sends them. @Provides annotation means that this method is available for binding as the root HTTP endpoint listener.

To define processing of the received requests, we override AsyncServlet.serve method with a lambda. We create a promise of HttpResponse with code 200 and “Hello World!” body. ActiveJ is fully asynchronous, so our HTTP Servlets are asynchronous too. A simple HttpResponse can be replaced with a Promise of HttpResponse to make it asynchronous.

Finally, we define main method and launch our server with launch method. This method injects dependencies, starts the application, runs it and stops it when needed.

3. Run the app

Now, let’s test the application. First, run HttpHelloWorldExample.main, then open your favourite browser and go to localhost:8080. You will receive a Hello World! message processed by the server. Congratulations, you’ve just created your first ActiveJ application!

What’s next?

To make ActiveJ more developer-friendly, we’ve created dozens of tutorials and examples of different scales, representing most of the platform’s capabilities. Click “Next” to get to the next tutorial. You can also explore ActiveJ docs first.