Hello,
I downloaded and installed the neo4j community edition.
My current aim is, to get a simple example on how to use neo4j with embedded java to run.
Therefore, I am looking on your documentation and especially the “HelloWorld” example (Program name: EmbeddedNeo4j.java) (http://neo4j.com/docs/stable/tutorials-java-embedded-hello-world.html ).
I want to compile and run this small example on the command line (cmd) using a JDK and including your libraries.
I have some questions:
· Setting up the environment
I want to identify the needed libs (jar-files) and include them in my javac / java call.
According to http://neo4j.com/docs/stable/tutorials-java-embedded-setup.html I have to include the libraries from a lib directory.
But in the community edition 2.2.1 I do not find any lib directory. I searched for .jar and found
c:\Program Files (x86)\Neo4j Community\.install4j\i4jruntime.jar
c:\Program Files (x86)\Neo4j Community\.install4j\ user.jar
c:\Program Files (x86)\Neo4j Community\bin\neo4j-desktop-2.2.1.jar
They all do not include the class org.neo4j.graphdb.Direction, which is imported in the example.
I looked, which jar has class Direction included, and found different versions neo4j-kernel-“version”.jar, especially neo4j-kernel-2.2.1.jar;
javac -classpath d:\jars_neo4j\neo4j-kernel-2.2.1.jar;D:\Programme\Java\java_ee_sdk-7u1\glassfish4\glassfish\lib\javaee.jar;d:\jars_neo4j\neo4j-io-2.2.1.jar EmbeddedNeo4j.java
Generates the following error:
D:\devneo4j>
javac -classpath d:\jars_neo4j\neo4j-kernel-2.2.1.jar;D:\Programme\Java\java_ee_sdk-7u1\glassfish4\glassfish\lib\javaee.jar;d:\jars_neo4j\neo4j-io-2.2.1.jar EmbeddedNeo4j.java
EmbeddedNeo4j.java:25: cannot access org.neo4j.graphdb.Direction
bad class file: d:\jars_neo4j\neo4j-kernel-2.2.1.jar(org/neo4j/graphdb/Direction.class)
class file has wrong version 51.0, should be 49.0
Please remove or make sure it appears in the correct subdirectory of the classpath.
import org.neo4j.graphdb.Direction;
I extracted the kernel jar to a directory / subfolder and included directly the classed needed , no change.
· Your Example code, especially starting transactions
In your example (
You write:
try ( Transaction tx = graphDb.beginTx() )
{
// Database operations go here
tx.success();
}
Both of my jdks (1.7, 1.8) do not like that, I changed this part to the program code of a previous version, (see the yellow part change/insertion).
Transaction tx = graphDb.beginTx();
try
{
….
// START SNIPPET: transaction
tx.success();
}
finally {
tx.finish();
}
In case your comment means, one has to change the example code – I find that misleading. People you be able to start with programs easily.
I hope, my changes are not the reason for the above error? I think, my changes are right?
My main questions is: how can I get the example to compile and run? I looked on the web, and found that other Java programmer get the error “class file has wrong version 51.0, should be 49.0”.
They changed the JDK or used javac –target 1.x commands. In my case it does not work.
Please give me some advice, on how to get the example to run.
Thank you in advance for your help!
Kind regards,
Peter
Dr. Peter Leven
Advanced Visual Solutions
::Virtual Engineering
Daimler Protics GmbH (ITM/PRO)
628-U058
89081 Ulm/Germany
Im Auftrag der/on behalf of Daimler AG
RD/FNT
71059 Sindelfingen/Germany
Phone |
|
|
Daimler Protics GmbH
Sitz und Registergericht/Domicile and Register Court: Stuttgart, HRB-Nr./Commercial Register No.: 23635
Geschäftsführer/Management: Dr. Klaus Grebner (CEO), Ralph Krückel (CFO), Winfried Rembold (COO)
If you are not the addressee, please inform us immediately that you have received this e-mail by mistake, and delete it. We thank you for your support. |