Neo4j stored procedures for Windows

Reading time ~1 minute

In the previous post I’ve written about new features in Neo4j. One of the new game changing functions were stored procedures. But, as I experienced, getting them to run on a Windows / .NET environment wasn’t that easy, and I was seeing “There is no procedure with the name …” more often then I wished for. So here is a short how to. Hope to save you some googling.

  1. JDK

    1. Download and install JDK 8.x from here. I’ve used 8u92 version.

    2. Set environment variable for JAVA_HOME pointing to JDK install location (in my case C:\Program Files\Java\jdk1.8.0_92). This can be done with some PowerShell:

      [Environment]::SetEnvironmentVariable("JAVA_HOME","C:\Program Files\Java\jdk1.8.0_92","Machine")
       

    The last parameter sets it as a machine level variable (visible for all users).

  2. Install Maven

    1. Download Maven from the official site
    2. Unzip it to a directory. In my case C:\Program Files\Maven
    3. Add environment variables for M2_HOME and MAVEN_HOME.
      [Environment]::SetEnvironmentVariable("M2_HOME","C:\Program Files\Maven","Machine")
      [Environment]::SetEnvironmentVariable("MAVEN_HOME","C:\Program Files\Maven","Machine")
    4. Update PATH environment.

      
      $path=[Environment]::GetEnvironmentVariable("Path","Machine")
      if($path -notcontains "%M2_HOME%\bin"){
         $newPath=$path+";"+ "%M2_HOME%\bin"
         [Environment]::SetEnvironmentVariable("Path",$newPath,"Machine")
      }
    5. Check. Run mvn -version in a new cmd.
  3. Neo4j

    1. If you haven’t, download the new Neo4j version (stored procedures are available in version 3.0 and up) from here.
    2. Add NEO4J_HOME environment path for Neo4j folder(in my case C:\Program Files\Neo4j CE 3.0.0).
      [Environment]::SetEnvironmentVariable("NEO4J_HOME","C:\Program Files\Neo4j CE 3.0.0","Machine")
       
    3. Clone neo4j-apoc-procedures. Again some PowerShell - should be executed with admin privileges:
      git clone http://github.com/jexp/neo4j-apoc-procedures
      cd neo4j-apoc-procedures
      mvn clean install
      copy target/apoc-1.0.0-SNAPSHOT.jar $Env:NEO4J_HOME/plugins/
    4. Edit Neo4j config.

      Open %userprofile%\AppData\Roaming\Neo4j Community Edition and add this entry (change the path if yours was different then in point 3.1):

      dbms.directories.plugins=c:/Program\ Files/Neo4j\ CE\ 3.0.0/plugins

    5. Restart Neo4j (if it was running)
    6. Check if it is OK and enter for example call apoc.help('search') in Neo4j cmd. And this should appear: Neo4j stored procedures working

Hi, I'm Szymon Warda. I write code, design IT systems, write this blog, tweet and speak at conferences. If You want to know more go here, or follow me: