pangguoming pangguoming - 5 months ago 27
Java Question

when i do a simple program with Neo4j java api , i get the following error


  1. My java version:java version "1.8.0_25"
    Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
    Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

  2. My Neo4j version: neo4j-community-2.3.0-RC1

  3. I imported all jar files in 'neo4j-community-2.3.0-RC1\lib' direcory to classpath with Eclipse

  4. I can find the messages.log file in "C:/TPNeo4jDB", the log is:
    2015-10-15 06:19:03.151+0000 INFO [o.n.k.i.f.CommunityFacadeFactory] No locking implementation specified, defaulting to 'community'

  5. I use windows 8 now



When my program runs
GraphDatabaseService db = dbFactory.newEmbeddedDatabase("C:/TPNeo4jDB");


I get error:

Exception in thread "main" java.lang.NullPointerException
at org.neo4j.kernel.impl.factory.CommunityEditionModule.determineEdition(CommunityEditionModule.java:142)
at org.neo4j.kernel.impl.factory.CommunityEditionModule.publishEditionInfo(CommunityEditionModule.java:132)
at org.neo4j.kernel.impl.factory.CommunityEditionModule.(CommunityEditionModule.java:122)
at org.neo4j.kernel.impl.factory.CommunityFacadeFactory.createEdition(CommunityFacadeFactory.java:50)
at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.newFacade(GraphDatabaseFacadeFactory.java:125)
at org.neo4j.kernel.impl.factory.CommunityFacadeFactory.newFacade(CommunityFacadeFactory.java:43)
at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.newFacade(GraphDatabaseFacadeFactory.java:108)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newDatabase(GraphDatabaseFactory.java:129)
at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:117)
at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:185)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:79)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:74)
at com.gongjiaolaile.view.Test.main(Test.java:9)

Answer

I guess that you are missing some libraries. First of all there are several places in Neo4j directory with libraries:

  • lib/
  • system/lib/

Second one - you should use build management tool like Maven.

In Neo4j documentation there is Using Neo4j embedded in Java applications section, that gives you overview how to use Neo4j. And here is described how to add Neo4j as dependency.

Comments