Goals If you are a Java developer, this guide provides an overview of options for connecting to Neo4j. While this guide is not comprehensive, it will introduce the different APIs and link to the relevant resources. Prerequisites You should be… Read more →

If you are a Java developer, this guide provides an overview of options for connecting to Neo4j. While this guide is not comprehensive, it will introduce the different APIs and link to the relevant resources.
You should be familiar with the graph database concepts and the property graph model. Having installed Neo4j and tried out our Cypher Query language helps too. When developing with Neo4j, please use JDK 7 or 8 and your favorite IDE.

Neo4j for Java Developers


Neo4j offers a rich set of integration possibilities for Java or JVM-language developers.

There are two ways of using Neo4j from the JVM. The standalone Neo4j Server can be installed on any machine and then accessed via its HTTP API. You can use any REST library you choose for any JVM language. The dedicated Neo4j drivers go beyond that by offering comprehensive APIs for integrating with graph-based applications.

But you can also run Neo4j embedded in your JVM process, much like HSQL or Derby. This is great for unit testing, but also for high performance / no-network setups. If you use Neo4j embedded, you can use the Neo4j Core-Java-API directly. Besides an object-oriented approach to the graph database, working with Nodes, Relationships, and Paths, it also offers highly customizable high-speed traversal- and graph-algorithm implementations. You can also choose from any useful drivers wrapping that API, which exist either for specific programming languages or that add interesting functionality.

One example is Spring Data Neo4j, which integrates tightly with the SpringFramework and offers Object-Graph mapping on top of Neo4j.

As a JVM developer you are also on the bright side when it comes to inserting large amounts of data into Neo4j. With its non-transactional, low-level batch-insertion API it can ingest millions of nodes and relationships in just seconds.

Follow the guides below to get you started.

The Example Project

The Neo4j example project is a small, one page webapp for the movies database built into the Neo4j tutorial. The front-end page is the same for all drivers: movie search, movie details, and a graph visualization of actors and movies. Each backend implementation shows you how to connect to Neo4j from each of the different languages and drivers.

You can learn more about our small, consistent example project across many different language drivers here. You will find the implementations for all drivers as individual GitHub repositories, which you can clone and deploy directly.

Using Neo4j Server with JDBC

Being a Java developer you’re probably familiar with JDBC as a way to work with relational databases, either directly or via abstractions like Spring’s JDBCTemplate or MyBatis. Many tools for ETL, Business Intelligence, and data management also use JDBC drivers to interact with relational databases.

As Cypher, like SQL, is a textual parametrizable query language that can return tabular results, it was possible for us to support the JDBC APIs and make a Neo4j-JDBC driver available. More details on how to use it can be found with our example project for Java-JDBC. There, we implement the backend as a minimal Java webapp that leverages Neo4j-JDBC to connect to Neo4j Server.

Object-Graph-Mapping with Neo4j-OGM

Developing Java Business Applications often requires mapping domain object networks to your database. The Neo4j-OGM library is a pure Java library that can store, read and query (annotated) domain objects using Neo4j. It uses Cypher statements execute those operations with Neo4j Server. The OGM supports tracking changes to minimize necessary updates and transitive persistence (reading and updating neighborhoods of an object).

Extending Neo4j Server with a Server Extension

A great way of accessing the high performance graph database directly from your Java code is to write a Neo4j Server extension. Then you get the double benefit of easy deployment and high performance database access.

A Server extension provides a Jersey JAX-RS REST endpoint with a protocol and granularity that you control, you use it to send and receive data structures of your domain.

After declaring the dependencies to Neo4j and Neo4j-Server-APIs you can create REST-resources that are deployed by Jersey at startup. Within those resources you can get the GraphDatabaseService and ExecutionEngine injected and use all Java APIs as well as executing Cypher directly. The path-finding and traversal APIs are also available.

The results of your graph operations are then collected and rendered as the format you want to expose, e.g. JSON, XML, plain text or binary.

The example project shows how you would do that for our movie application endpoints.


JCypher provides seamlessly integrated Java access to Neo4j at different levels of abstraction:

At the topmost level of abstraction, JCypher allows you to map complex business domains to graph databases. You can take an arbitrarily complex graph of domain objects or POJOs and store it in a straightforward way into Neo4j for later retrieval. You do not need to modify your domain object classes in any way, there is also no need for annotations. JCypher provides a default mapping out of the box.

At the same level of abstraction, Domain Queries provide the power and expressiveness of queries on a graph database, while being formulated on domain objects or on types of domain objects, respectively. The true power of Domain Queries comes from the fact, that the graph of domain objects is backed by a graph database.

At the next lower level of abstraction – access to graph databases – is provided based on a generic graph model. While simple, the model allows you to easily navigate and manipulate graphs.

At the bottom level of abstraction, a native Java DSL in the form of a fluent Java API allows you to intuitively and comfortably formulate queries against Neo4j.



Neo4j Grails Plugin

Author: Stefan Armbruster

A plugin that integrates the Neo4j graph database into Grails, providing a GORM API onto it




Author: Michael Klishin, Rohit Aggarwal

An idiomatic, feature-rich Clojure client which supports (almost) all Neo4k REST API features and is constantly tested against bleeding edge server changes, like the Cypher language improvements.


Author: Jozef Wagner Clojure wrapper for Neo4j, a graph database, in embedded JVM mode.




Author: Wes Freeman

A Cypher-oriented Scala library modeled after the Play! framework’s Anorm library.


Hibernate OGM

Authors: Davide D’Alto, Gunnar Moelling, Emmanuel Bernard

Hibernate Object/Grid Mapper (OGM) with Neo4j Support.