Embedding Neo4j in your Java application

After selecting the appropriate edition for your platform, you can embed Neo4j in your Java application by including the Neo4j library JARs in your build. The following sections show how to do this by either altering the build path directly or by using dependency management.

Adding Neo4j as a dependency

You can either go with the top-level artifact or include the individual components directly. The following examples use the top-level artifact approach.

The examples are only valid for Neo4j Community Edition.

To add Neo4j Enterprise Edition as a dependency, please get in contact with Neo4j Professional Services. See Operations Manual → Introduction for details about the Community and Enterprise Editions.

Maven

Add the dependency to your project along the lines of the snippet below. This is usually done in the pom.xml file found in the root directory of the project.

<project>
...
 <dependencies>
  <dependency>
   <groupId>org.neo4j</groupId>
   <artifactId>neo4j</artifactId>
   <version>2026.09.0</version>
  </dependency>
  ...
 </dependencies>
...
</project>

Where the artifactId is found in the Editions table.

Eclipse and Maven

For development in Eclipse, it is recommended to install the m2e plugin and let Maven manage the project build classpath instead. This also adds the possibility to build your project both via the command line with Maven and have a working Eclipse setup for development.

Ivy

Make sure to resolve dependencies from Maven Central. You can use this configuration in your ivysettings.xml file:

<ivysettings>
  <settings defaultResolver="main"/>
  <resolvers>
    <chain name="main">
      <filesystem name="local">
        <artifact pattern="${ivy.settings.dir}/repository/[artifact]-[revision].[ext]" />
      </filesystem>
      <ibiblio name="maven_central" root="http://repo1.maven.org/maven2/" m2compatible="true"/>
    </chain>
  </resolvers>
</ivysettings>

With that in place, add Neo4j by adding the following dependency to your ivy.xml file:

..
<dependencies>
  ..
  <dependency org="org.neo4j" name="neo4j" rev="2026.09.0"/>
  ..
</dependencies>
..

The name can be found in the Editions table.

Gradle

An example Gradle build script for including the Neo4j libraries:
def neo4jVersion = "2026.09.0"
apply plugin: 'java'
repositories {
   mavenCentral()
}
dependencies {
   implementation "org.neo4j:neo4j:${neo4jVersion}"
}

The coordinates (org.neo4j:neo4j in the example) are found in the Editions table.

Starting and stopping

To start the embedded DBMS you instantiate a org.neo4j.dbms.DatabaseManagementService and get the org.neo4j.graphdb.GraphDatabaseService as follows:

managementService = new DatabaseManagementServiceBuilder( databaseDirectory ).build();
graphDb = managementService.database( DEFAULT_DATABASE_NAME );
registerShutdownHook( managementService );

If you are using the Enterprise Edition of Neo4j in embedded mode, you have to create your database with the com.neo4j.dbms.api.EnterpriseDatabaseManagementServiceBuilder to enable the Enterprise Edition features. If you intend to operate embedded clusters, you need to provide the appropriate configuration to the instances you create (for example, ports and discovery endpoints). For maintainability purposes, you can define your embedded DBMS configuration in the neo4j.conf file as follows:

server.default_advertised_address=core01.example.com
server.default_listen_address=0.0.0.0
dbms.cluster.discovery.resolver_type=LIST
dbms.cluster.endpoints=core01.example.com,core02.example.com,core03.example.com
server.bolt.enabled=true
server.http.enabled=true
var managementService = new EnterpriseDatabaseManagementServiceBuilder( homeDirectory )
    .loadPropertiesFromFile( Path.of( "/path/to/neo4j.conf" ) )
    .build();

It is also possible to use the builder and specify all the parameters programmatically: