Connect to Neo4j from different programming languages using GraalVM.
Setup steps (basic GraalVM and Neo4j install):
-
Download Neo4j Desktop, community server, or start up a sandbox from neo4j.com
-
Follow download instructions to set up the database and start it
-
Download and install GraalVM SDK. GraalVM docs shows one way, but I used SDKMAN! to install it and set GraalVM’s Java (currently
20.3.0.r11-grl
) as my default SDK. -
Install any GraalVM languages you intend to use with the GraalVM Updater (gu). Use command syntax
gu install <language>
. Note: there may be a couple of other steps for dependencies to run a language, see the docs for each language. -
Create and start an instance of Neo4j (if you are using Neo4j Sandbox, then this is already done for you).
Steps to run the examples:
-
Download Java driver (4.0.3) and reactive stream (1.0.3) dependencies.
-
Clone this repository and open in your preferred IDE
-
For each program language you intend to run, open the file and change the password on the
authTokens.basic('neo4j', 'Testing123')
line to be the password you set for your database. Note: If using Neo4j Sandbox, you will also need to modify the line above the authTokens with the sandbox connection BOLT URL. -
Save and close the program(s), then build the project
-
Navigate to
src/main/java
folder and run one of the programs using the related command below.
#Python
graalpython --jvm graalvm-test.py
#Javascript
js --jvm neo4j-graalvm-javascript-example.js
#R
Rscript --jvm neo4j-graalvm-fastr-example.R
#Ruby
#Ruby does not (yet?) support adding Java dependencies to classpath, so have to set them on the command line
export CLASSPATH=../../../target/lib/neo4j-java-driver-4.0.3.jar:../../../target/lib/reactive-streams-1.0.3.jar
truffleruby --jvm --vm.cp=$CLASSPATH neo4j-graalvm-ruby-example.rb