21.1. Introduction

21.1.1. How to add configuration settings

To gain good performance, these are the things to look into first:

21.1.1. How to add configuration settings

When creating the embedded Neo4j instance it is possible to pass in parameters contained in a map where keys and values are strings.

Map<String, String> config = new HashMap<String, String>();
config.put( "neostore.nodestore.db.mapped_memory", "10M" );
config.put( "string_block_size", "60" );
config.put( "array_block_size", "300" );
EmbeddedGraphDatabase db = new EmbeddedGraphDatabase( "target/mydb", config  );

If no configuration is provided, the Database Kernel will try to determine suitable settings from the information available via the JVM settings and the underlying operating system.

The JVM is configured by passing command line flags when starting the JVM. The most important configuration parameters for Neo4j are the ones that control the memory and garbage collector, but some of the parameters for configuring the Just In Time compiler are also of interest.

This is an example of starting up your applications main class using 64-bit server VM mode and a heap space of 1GB:

java -d64 -server -Xmx1024m -cp /path/to/neo4j-kernel.jar:/path/to/jta.jar:/path/to/your-application.jar com.example.yourapp.MainClass

Looking at the example above you will also notice one of the most basic command line parameters: the one for specifying the classpath. The classpath is the path in which the JVM searches for your classes. It is usually a list of jar-files. Specifying the classpath is done by specifying the flag -cp (or -classpath) and then the value of the classpath. For Neo4j applications this should at least include the path to the Neo4j neo4j-kernel.jar and the Java Transaction API (jta.jar) as well as the path where the classes for your application are located.

[Tip]Tip

On Linux, Unix and Mac OS X each element in the path list are separated by a colon symbol (:), on Windows the path elements are separated by a semicolon (;).

When using the Neo4j REST server, see Section 17.2, “Server Configuration” for how to add configuration settings for the database to the server.