1. Install Juneau
Juneau requires Java 17+. All modules are published to Maven Central under the group id
org.apache.juneau.
Set the version
Define the version once as a Maven property; every snippet in these docs uses ${juneau.version}.
<properties>
<juneau.version>10.0.0-SNAPSHOT</juneau.version>
</properties>
<repositories>
<repository>
<id>apache-snapshots</id>
<url>https://repository.apache.org/snapshots/</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
These docs describe 10.0, which is a pre-release (10.0.0-SNAPSHOT). Maven Central currently has only 9.2.0, the latest release (see Downloads). To build against 10.0 you need the Apache snapshots repository shown above; for 9.2.0, set juneau.version to 9.2.0 and drop the <repositories> block. The juneau-bom and the newer modules shown in these docs are 10.0 only.
Import the BOM
Import juneau-bom once, then leave the version off every Juneau dependency. See
Dependency Management for details.
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.juneau</groupId>
<artifactId>juneau-bom</artifactId>
<version>${juneau.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Pick your modules
| You want to... | Add |
|---|---|
| Serialize and parse beans (JSON, XML, HTML, YAML, and more) | juneau-marshall |
| Build a REST API | juneau-rest-server (plus one of the starters or a microservice bundle to run it) |
| Call REST APIs | juneau-rest-client (see Choosing a REST Client) |
| Test REST code without a network | juneau-rest-mock |
<dependencies>
<dependency>
<groupId>org.apache.juneau</groupId>
<artifactId>juneau-marshall</artifactId>
</dependency>
</dependencies>
juneau-marshall needs no third-party dependencies. The full list of modules, with their
prerequisites, is in the Ecosystem Overview.
Create the walkthrough project
The next three pages build one project. Make an empty directory, juneau-demo, and save this as
juneau-demo/pom.xml. It combines the version property, snapshot repository, and BOM from above with the four
modules the walkthrough uses: the Jetty microservice bundle (which brings in juneau-marshall and
juneau-rest-server), the REST client, and the mock client.
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<maven.compiler.release>17</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<juneau.version>10.0.0-SNAPSHOT</juneau.version>
</properties>
<repositories>
<repository>
<id>apache-snapshots</id>
<url>https://repository.apache.org/snapshots/</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.juneau</groupId>
<artifactId>juneau-bom</artifactId>
<version>${juneau.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.juneau</groupId>
<artifactId>juneau-microservice-jetty-bundle</artifactId>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.apache.juneau</groupId>
<artifactId>juneau-rest-client</artifactId>
</dependency>
<dependency>
<groupId>org.apache.juneau</groupId>
<artifactId>juneau-rest-mock</artifactId>
</dependency>
</dependencies>
</project>
Then create the source directory the later pages write into:
mkdir -p juneau-demo/src/main/java/com/example/demo
cd juneau-demo
Every Java file in this walkthrough goes in src/main/java/com/example/demo/ and starts with
package com.example.demo;.