---
title: Java
summary: Add the Java SDK (nl.bimbase.bimworks:sdk, generated from the OpenAPI) or the classic Java client from the private Maven repository, and check that it connects.
order: 20
languages: [java]
terms: [sdk, api-token]
see-also: [reference/sdk/java, reference/java, reference/sdk, how-to/install/dotnet, how-to/install/downloads, how-to/auth/log-in-with-an-api-token, tutorials/java/quick-start]
notion: https://bimbase.notion.site/Maven-Java-c71a36aed8a848648a95852e208660db
---

# Java

For Java developers who add BIM.works to a Maven or Gradle project. There are two Java [[term:sdk|SDKs]], both in the same private repository ([[page:reference/sdk]] compares them):

- the **Java SDK**, `nl.bimbase.bimworks:sdk`, generated from the OpenAPI document: one method per operation, over HTTPS. Use it for a new integration; its reference is [[page:reference/sdk/java]].
- the **classic Java SDK**, `nl.bimbase.bimworks:client`, the hand-written client of the task API over HTTP and WebSocket; its reference is [[page:reference/java]], and [[page:tutorials/java/quick-start]] is a first program.

## Before you start

- A JDK: **17 or newer**, for every artifact on this page.
- Maven 3.6 or newer (or Gradle).
- Credentials for the private repository `https://maven.bim.works`. Your company portal has them, or ask support@bimbase.nl.

## 1. Put the credentials in `settings.xml`

The repository is private, so Maven needs a `<server>` entry whose `id` matches the repository id used below. The file is `~/.m2/settings.xml`:

```xml {#settings-xml}
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
  <servers>
    <server>
      <id>BIM.works</id>
      <username>[your username]</username>
      <password>[your password]</password>
    </server>
  </servers>
</settings>
```

## 2. Add the repository and the dependency

Use the version that matches your BIM.works server (the version pill at the top of this page is the server's); the SDKs and the server are released in lockstep, see [[page:explanation/versioning-and-compatibility]]. For the Java SDK:

```xml {#pom-sdk}
<dependencies>
  <dependency>
    <groupId>nl.bimbase.bimworks</groupId>
    <artifactId>sdk</artifactId>
    <version>3.0.0-beta.192</version>
  </dependency>
</dependencies>
<repositories>
  <repository>
    <id>BIM.works</id>
    <url>https://maven.bim.works/artifactory/BIM.works</url>
  </repository>
</repositories>
```

It brings Jackson (`jackson-databind`, `jackson-datatype-jsr310`, `jackson-databind-nullable`) and uses the JDK's own `java.net.http` client. For the classic SDK the artifact is `client`:

```xml {#pom}
<dependencies>
  <dependency>
    <groupId>nl.bimbase.bimworks</groupId>
    <artifactId>client</artifactId>
    <version>3.0.0-beta.192</version>
  </dependency>
</dependencies>
<repositories>
  <repository>
    <id>BIM.works</id>
    <url>https://maven.bim.works/artifactory/BIM.works</url>
  </repository>
</repositories>
```

With Gradle:

```text {#gradle}
repositories {
    maven {
        url = uri("https://maven.bim.works/artifactory/BIM.works")
        credentials {
            username = "[your username]"
            password = "[your password]"
        }
    }
}
dependencies {
    implementation("nl.bimbase.bimworks:sdk:3.0.0-beta.192")      // the Java SDK
    implementation("nl.bimbase.bimworks:client:3.0.0-beta.192")   // or the classic SDK
}
```

### What comes with the classic SDK

The direct dependencies of `client`, all resolved from the same repository:

| Artifact | Used for |
|---|---|
| `nl.sascom.backplane:client` | The transport: HTTP and WebSocket connections (Jetty client), requests, tasks and streams. |
| `nl.bimbase.bimworks:common` | Types shared with the server: Qids, units, error codes, the model classes. |
| `jakarta.xml.bind:jakarta.xml.bind-api` | XML serialisation. |

Everything else is transitive. Two of those matter to you: **Jackson** (many SDK methods accept or return `ObjectNode`/`ArrayNode`) and the **SLF4J API**. The client logs through SLF4J and ships no binding; add Logback or another binding to see its log output.

## 3. Or use the shaded classic artifact {#3-or-use-the-shaded-artifact}

`clientshaded` bundles the classic client and its dependencies into one jar, for an application whose own Jetty clashes with the client's. It renames the packages of four of the bundled libraries under `nl.bimbase.bimworks.`: Jetty (`org.eclipse.jetty`), Eclipse Collections, JavaFastPFOR and brotli4j. The other bundled libraries keep their package names — Jackson, Guava, commons-io, commons-codec, commons-lang3, commons-compress, HttpClient 5, RoaringBitmap, LZ4, Javassist, Bouncy Castle, zstd-jni and jul-to-slf4j among them — so a different version of one of those on your classpath still clashes, and because they are inside the jar, the shaded artifact's POM no longer lists them. Only `slf4j-api` is left out of the jar and stays a dependency, so one SLF4J interface is shared with your logging binding.

```xml {#pom-shaded}
<dependency>
  <groupId>nl.bimbase.bimworks</groupId>
  <artifactId>clientshaded</artifactId>
  <version>3.0.0-beta.192</version>
</dependency>
```

```note
Like `client`, the shaded artifact runs on Java 17 or newer. The four renamed libraries log under their new names (`nl.bimbase.bimworks.org.eclipse.jetty…`); the client itself logs under `nl.bimbase.bimworks` and `nl.sascom.backplane`, and the other bundled libraries under their own names.
```

The former `clientlegacy` artifact (`javax.servlet` instead of `jakarta.servlet`) is discontinued since BIM.works 1.3; the shaded artifact serves the same purpose.

## Check

With the Java SDK, run the program below: it logs in with your [[term:api-token|API token]] and prints the UUID of your root node. Every example of the Java SDK has this shape ([[page:reference/sdk/java#example-shape]]).

```sdk-example {#check-sdk}
operation: GetRootNodeUuid
languages: java
```

With the classic SDK, compile and run a class that creates a factory and asks the server for its version. This needs no API token: an anonymous login may call `GetApplicationVersion`.

```java {#check}
import nl.bimbase.bimworks.client.BimWorksClient;
import nl.bimbase.bimworks.client.BimWorksClientFactory;

public class Check {
	public static void main(String[] args) throws Exception {
		try (BimWorksClientFactory factory = new BimWorksClientFactory(BIM_WORKS_ADDRESS);
				BimWorksClient client = factory.createAnonymousClient()) {
			System.out.println(client.getApplicationVersion());
		}
	}
}
```

It prints a JSON object with the server's version. `BimWorksClientFactory.createAnonymousClient()` and `BimWorksClient.getApplicationVersion()` are described in [[page:reference/java]]. Next: [[page:how-to/auth/log-in-with-an-api-token]].
