Java Setup HowTo

From Neo4j Wiki

Jump to: navigation, search

Unlike many other database engines, Neo4j is not based on a network server. Instead, it is a set of Java libraries that must be linked into the current application. This page gives link to information on installing Java and linking the Neo4j libraries into your application.

Contents

[edit] Downloading and Installation of Java

Note: Developing using Neo4j requires Java JDK version 5 or later. ("JDK" is the Java Development Kit)

[edit] Linux, Unix, etc.

With the exception of Mac OS X and Solaris (see below), most Unixish systems do not support Java "out of the box". So, you'll need to go to the archive/packaging system used by your OS and investigate how to download and install Java.

Installation information for OpenJDK on Ubuntu, RedHat/Fedora/CentOS, openSUSE and Debian: OpenJDK download and install

Ubuntu

The JDK from Sun can also be obtained directly from Sun Java developer resources.

[edit] Mac OS X

Mac OS X supplies a pretty full set of Java infrastructure, but you should probably install the Developer Tools (aka Xcode) to be sure you have the full range of Unixish commands, etc.

[edit] MS Windows

[edit] Solaris

Solaris supplies a full set of Java infrastructure.

[edit] Linking the Neo4j libraries

To be able to use Neo4j from your code, the Neo4j libraries should be added to the classpath of the project.

The recommended way to manage the classpath is to use Maven (or a similar tool). The Getting Started Guide shows how to configure a Maven project to include Neo4j libraries.

A detailed guide on how to manage the classpath manually is found at the Mind Products classpath page. The classpath may also be referred to as the build path, see the Eclipse help on how to use it. For Netbeans, see Gettings started with NB.


[edit] Configuration

Please refer to the Configuration Settings page for information on configuring Java.

[edit] Building from source

The latest builds of the Neo4j components are always found in the Maven 2 repository. If you however need to build something from source (typically you'd need this for packages in the laboratory), this is how to do it:

Install Maven 2. If on Unix etc. you'll probably find it in the package management system. This is how it's done in Ubuntu;

sudo apt-get install maven2

In other cases, downloads and installation instructions are found at the Maven download page

Configure the Maven 2 settings file. The file should be located as follows: ${user.home}/.m2/settings.xml - create it if it doesn't exist. The Neo4j Maven 2 repository should be added to the settings, for simplicity here's a full settings.xml (click the link to download) example:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <profiles>
    <profile>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <repositories>
        <repository>
          <id>neo4j-public-repository</id>
          <name>Publically available Maven 2 repository for Neo4j</name>
          <url>http://m2.neo4j.org</url>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
      </repositories>
    </profile>
  </profiles>
</settings>

Build the project by issuing the following command:

mvn package

This will produce jar files and other artifacts of the project, which will be placed in the target/ directory inside the project.

Personal tools