Installation
To start creating a Neo4j Java application, you first need to install the Java driver and get a Neo4j database instance to connect to.
|
Server compatibility
The latest driver in the 6.x series supports connection to Neo4j instances version 4.4.x, 5.x, 2025.x, and 2026.x.
It is also guaranteed to be forward-compatible with the next major release.
|
| The driver requires Java 17 or higher. |
Install the driver
If you already have a Maven project, you may add the driver as a dependency in your pom.xml file:
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>
<version>6.1.0</version>
</dependency>
How to create a Maven project for a Neo4j Java application?
If you are new to Maven, you may download the Neo4j demo app example project and use it as a base to experiment with the driver and build your application.
The file App.java provides a skeleton application.
You may compile and run the project with the commands:
mvn package
java -jar target/neo4j-demo-app-1.0-SNAPSHOT-jar-with-dependencies.jar
For other dependency management systems, refer to the driver’s package page.
Get a Neo4j instance
You need a running Neo4j database in order to use the driver with it.
The easiest way to spin up a local instance is through a Docker container (requires docker.io).
The command below runs the latest Neo4j version in Docker, setting the admin username to neo4j and password to secretgraph:
docker run \
-p7474:7474 \ # forward port 7474 (HTTP)
-p7687:7687 \ # forward port 7687 (Bolt)
-d \ # run in background
-e NEO4J_AUTH=neo4j/secretgraph \ # set login credentials
neo4j:latest
Alternatively, you can obtain a free cloud instance through Aura.
You can also install Neo4j on your system, or use Neo4j Desktop to create a local development environment (not for production).
Glossary
- LTS
-
A Long Term Support release is one guaranteed to be supported for a number of years. Neo4j 4.4 and 5.26 are LTS versions.
- Aura
-
Aura is Neo4j’s fully managed cloud service. It comes with both free and paid plans.
- Cypher
-
Cypher is Neo4j’s graph query language that lets you retrieve data from the database. It is like SQL, but for graphs.
- APOC
-
Awesome Procedures On Cypher (APOC) is a library of (many) functions that can not be easily expressed in Cypher itself.
- Bolt
-
Bolt is the protocol used for interaction between Neo4j instances and drivers. It listens on port 7687 by default.
- ACID
-
Atomicity, Consistency, Isolation, Durability (ACID) are properties guaranteeing that database transactions are processed reliably. An ACID-compliant DBMS ensures that the data in the database remains accurate and consistent despite failures.
- eventual consistency
-
A database is eventually consistent if it provides the guarantee that all cluster members will, at some point in time, store the latest version of the data.
- causal consistency
-
A database is causally consistent if read and write queries are seen by every member of the cluster in the same order. This is stronger than eventual consistency.
- NULL
-
The null marker is not a type but a placeholder for absence of value. For more information, see Cypher → Working with
null. - transaction
-
A transaction is a unit of work that is either committed in its entirety or rolled back on failure. An example is a bank transfer: it involves multiple steps, but they must all succeed or be reverted, to avoid money being subtracted from one account but not added to the other.
- backpressure
-
Backpressure is a force opposing the flow of data. It ensures that the client is not being overwhelmed by data faster than it can handle.
- bookmark
-
A bookmark is a token representing some state of the database. By passing one or multiple bookmarks along with a query, the server will make sure that the query does not get executed before the represented state(s) have been established.
- transaction function
-
A transaction function is a callback executed by an
executeReadorexecuteWritecall. The driver automatically re-executes the callback in case of server failure. - Driver
-
A
Driverobject holds the details required to establish connections with a Neo4j database.