<commit_before>---
layout: documentation
title: Installing the Java driver
title_image: /assets/images/docs/driver-languages/java.png
docs_active: install-drivers
permalink: docs/install-drivers/java/
---
{% include docs/install-driver-docs-header.md %}

# Installation #

## Using Maven ##

If you're using Maven, add this to your `pom.xml` file:

```xml
<dependencies>
  <dependency>
    <groupId>com.rethinkdb</groupId>
    <artifactId>rethinkdb-driver</artifactId>
    <version>2.2-beta-1</version>
  </dependency>
</dependencies>
```

## Using Gradle ##

If you're using Gradle, modify your `build.gradle` file:

```groovy
dependencies {
    compile group: 'com.rethinkdb', name: 'rethinkdb-driver', version: '2.2-beta-1'
}
```

## Using Ant ##

If you're using Ant, add the following to your `build.xml`:

```xml
<artifact:dependencies pathId="dependency.classpath">
  <dependency groupId="com.rethinkdb" artifactId="rethinkdb-driver" version="2.2-beta-1" />
</artifact:dependencies>
```

## Using SBT ##

If you're using SBT, add the following to your `build.sbt`:

```scala
libraryDependencies += "com.rethinkdb" % "rethinkdb-driver" % "2.2-beta-1"
```

# Usage #

You can use the drivers from Java like this:

```java
import com.rethinkdb.RethinkDB;
import com.rethinkdb.gen.exc.ReqlError;
import com.rethinkdb.gen.exc.ReqlQueryLogicError;
import com.rethinkdb.model.MapObject;
import com.rethinkdb.net.Connection;


public static final RethinkDB r = RethinkDB.r;

Connection conn = r.connection().hostname("localhost").port(28015).connect();

r.db("test").tableCreate("tv_shows").run(conn);
r.table("tv_shows").insert(r.hashMap("name", "Star Trek TNG")).run(conn);
```

__Note:__ RethinkDB connection objects are not thread-safe. It's recommended that applications open a separate connection per thread, or establish a connection pool.

# Next steps #

{% infobox %}
Move on to the [ten-minute guide](/docs/guide/java/) and learn how to use RethinkDB.<commit_msg>Updated Java driver version to 2.3.0<commit_after>---
layout: documentation
title: Installing the Java driver
title_image: /assets/images/docs/driver-languages/java.png
docs_active: install-drivers
permalink: docs/install-drivers/java/
---
{% include docs/install-driver-docs-header.md %}

# Installation #

## Using Maven ##

If you're using Maven, add this to your `pom.xml` file:

```xml
<dependencies>
  <dependency>
    <groupId>com.rethinkdb</groupId>
    <artifactId>rethinkdb-driver</artifactId>
    <version>2.3.0</version>
  </dependency>
</dependencies>
```

## Using Gradle ##

If you're using Gradle, modify your `build.gradle` file:

```groovy
dependencies {
    compile group: 'com.rethinkdb', name: 'rethinkdb-driver', version: '2.3.0'
}
```

## Using Ant ##

If you're using Ant, add the following to your `build.xml`:

```xml
<artifact:dependencies pathId="dependency.classpath">
  <dependency groupId="com.rethinkdb" artifactId="rethinkdb-driver" version="2.3.0" />
</artifact:dependencies>
```

## Using SBT ##

If you're using SBT, add the following to your `build.sbt`:

```scala
libraryDependencies += "com.rethinkdb" % "rethinkdb-driver" % "2.3.0"
```

# Usage #

You can use the drivers from Java like this:

```java
import com.rethinkdb.RethinkDB;
import com.rethinkdb.gen.exc.ReqlError;
import com.rethinkdb.gen.exc.ReqlQueryLogicError;
import com.rethinkdb.model.MapObject;
import com.rethinkdb.net.Connection;


public static final RethinkDB r = RethinkDB.r;

Connection conn = r.connection().hostname("localhost").port(28015).connect();

r.db("test").tableCreate("tv_shows").run(conn);
r.table("tv_shows").insert(r.hashMap("name", "Star Trek TNG")).run(conn);
```

__Note:__ RethinkDB connection objects are not thread-safe. It's recommended that applications open a separate connection per thread, or establish a connection pool.

# Next steps #

{% infobox %}
Move on to the [ten-minute guide](/docs/guide/java/) and learn how to use RethinkDB.
{'fraction_non_alphanumeric': 0.14991136996708027, 'fraction_numerical': 0.009369460622942517, 'mean_word_length': 4.895522388059701, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3201421', 'n_tokens_mistral': 1418, 'n_tokens_neox': 1308, 'n_words': 334}