Chapter 32. Using Neo4j embedded in Java applications

It’s easy to use Neo4j embedded in Java applications. In this chapter you will find everything needed — from setting up the environment to doing something useful with your data.

[Warning]Warning

When running your own code and Neo4j in the same JVM, there are a few things you should keep in mind:

  • Don’t create or retain more objects than you strictly need to. Large caches in particular tend to promote more objects to the old generation, thus increasing the need for expensive full garbage collections.
  • Don’t use internal Neo4j APIs. They are internal to Neo4j, they may change in future releases and break the intended behavior of your code.
  • Don’t enable the -XX:+TrustFinalNonStaticFields JVM flag when running in embedded mode.