To experiment with Neo4j and Java during this course you will need to setup a development environment.
Get started
The repository, neo4j-graphacademy/drivers-java, has been created for this course. It contains any starter code and resources you need.
You can use a GitHub codespace as an online IDE and workspace for this course. It will automatically clone the course repository and set up your environment.
GitHub Codespaces
You will need to login with a GitHub account. The GitHub Codespaces free monthly usage will cover the duration of this course.
The repository contains an example Maven project with the required dependencies and a pom.xml
file.
Develop on your local machine
You will need Java 17 or higher installed.
You can check your version by running java -version
.
To download Java, you can choose from many supported vendor options. For example, Azul’s JDK or hOpenJDK.
Clone the github.com/neo4j-graphacademy/drivers-java repository:
git clone https://github.com/neo4j-graphacademy/drivers-java
Fork the repository
You can fork the repository and have a copy for future reference.Install the project and dependencies using Maven:
cd drivers-java
./mvnw clean install -U -DskipTests
You do not need to create a Neo4j database as you will use the provided sandbox instance.
Driver installation
The Neo4j driver is included in the pom.xml
file, so you do not need to install it separately.
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>
<version>5.28.4</version>
</dependency>
Click to view the complete pom.xml file
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.neo4j.app</groupId>
<artifactId>drivers-java</artifactId>
<version>1.0-SNAPSHOT</version>
<name>drivers-java</name>
<url>https://github.com/neo4j-graphacademy/drivers-java</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>17</maven.compiler.release>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.11.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>
<version>5.28.4</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.4.0</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.3.0</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.2</version>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.12.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.6.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Setup the environment
Create a new /src/main/resources/application.properties
file and copy the contents of the example.properties
file into it.
Fill in the required values:
NEO4J_URI=
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=
Update the Neo4j sandbox connection details:
- NEO4J_URI
-
bolt://{sandbox-ip}:{sandbox-boltPort}
- NEO4J_USERNAME
-
{sandbox-username}
- NEO4J_PASSWORD
-
{sandbox-password}
Test your setup
You can test your setup by running the test - src/test/java/com/neo4j/app/AppTest.java
.
The test will attempt to load the values in the application.properties
file and connect to the Neo4j sandbox.
./mvnw test
You will see Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
and a BUILD SUCCESS
message if you have set up your environment correctly.
If any tests fail, check the contents of the .application.properties
file.
Continue
When you are ready, you can move on to the next task.
Summary
You have setup your environment and are ready to start this module.