Getting Started In One Minute Guide
From NeoWiki
This is a compressed summary of the slightly more verbose Getting Started Guide. Please refer to it if something here is unclear.
- If you don't use Maven: Download the Neo release and add the Neo and JTA jars to your classpath.
- If you do use Maven: Check the Maven2 info here and add it to your
pom.xml. - Declare your relationship types and start Neo (the complete code is here: One Minute Guide Complete Code):
public enum MyRelationshipTypes implements RelationshipType
{
KNOWS
}
...
NeoService neo = new EmbeddedNeo( "var/base" );
- Create a small node space:
Node firstNode = neo.createNode(); Node secondNode = neo.createNode(); Relationship relationship = firstNode.createRelationshipTo( secondNode, MyRelationshipTypes.KNOWS ); firstNode.setProperty( "message", "Hello, " ); secondNode.setProperty( "message", "world!" ); relationship.setProperty( "message", "brave Neo " );
- Recall that Neo is fully transactional, so wrap everything in transactions:
Transaction tx = Transaction.begin();
try
{
// all Neo operations that work with the node space, for example:
// Node firstNode = neo.createNode();
// ... etc ...
tx.success();
}
finally
{
tx.finish();
neo.shutdown();
}
- Print the result and you're done:
System.out.print( firstNode.getProperty( "message" ) ); System.out.print( relationship.getProperty( "message" ) ); System.out.print( secondNode.getProperty( "message" ) );
- Check out the verbose version of this guide, the complete code, the javadocs at http://api.neo4j.org/current, the basic code snippets PDF to learn the traverser framework, the guide to the NeoShell, the documentation page and sign up on the mailing list.

