Setting up the Project

We have put together a project with all the boilerplate in place. As you move through this course, you will learn some theory and then how to apply it to the example project.

In order to run the project, you must make sure that Java is installed.

Setup Java

We are assuming that in taking this course, you already have at least a basic understanding of Java.

If you haven’t already installed Java, you should install Java using sdkman with sdk install java 17-open and either set it as default or set to use it in your current shell.

sh
Install Java
sdk install java 17-open
sdk use java 17-open

Installing SDKMAN

If you haven’t already done so, you can install sdkman at sdkman.io

The project has been written to work with Java version 17.

You can verify that the installation is successful by running the following command in the command line:

sh
Verify Java Version
java --version

You will also need a package manager to install the dependencies and build and run the project. We use Apache Maven with this project. Maven is not included with Java, but you can also install it with sdkman.

sh
Install Maven
sdk install maven

Clone the Repository

You can obtain a copy of the project source code by cloning the neo4j-graphacademy/app-java repository from Github. Or, if you prefer, you can also download a zip file with the source.

Learn how to interact with Neo4j from Java using the Neo4j Java DriverHTTPS

To clone the repository without logging in via HTTPS, you can run the following command to clone the repository:

shell
Clone Repository Using HTTPS
git clone https://github.com/neo4j-graphacademy/app-java.git
Learn how to interact with Neo4j from Java using the Neo4j Java DriverSSH

If you have a GitHub account configured with SSH access, you can run the following command to clone the repository:

shell
Clone Repository using SSH
git clone git@github.com:neo4j-graphacademy/app-java.git
Learn how to interact with Neo4j from Java using the Neo4j Java DriverGitHub CLI

If you have the GitHub CLI installed, you can run the following command to clone the repository:

sh
Clone Repository using the GitHub CLI
gh repo clone neo4j-graphacademy/app-java
Learn how to interact with Neo4j from Java using the Neo4j Java DriverDownload Zip File

Click the following link to download the source as a .zip file.

https://github.com/neo4j-graphacademy/app-java/archive/refs/heads/main.zip.

Install Dependencies

Once you have cloned the repository, navigate to the folder in your terminal and run the following command to install the dependencies and test the project: mvn verify

sh
Install Dependencies using Maven
mvn verify

You can view a full list of dependencies by opening pom.xml.

Failing tests

You will notice that some tests fail when you run mvn verify. During the course you will complete the project and resolve the issues.

Errors while installing dependencies?

This project has been written using Java version 17. If you are using the wrong version, you may experience errors when trying to install the dependencies.

If you experience any problems, run the following commands to set your Java configuration to the correct version for your current terminal session:

sh
Use Java Version 17-open
sdk use java 17-open

Application Configuration

This project uses System properties to manage configuration variables for this project. When the AppUtils.loadProperties() method is called, the application.properties file in the src/main/resources of the project is parsed and all settings made accessible from System.getProperty.

The project contains an example file at example.properties. You can run the following command from the root folder in your terminal window to copy the example file to application.properties.

sh
cp src/main/resources/example.properties src/main/resources/application.properties

Start the Project

To start the project, run the following command:

sh
Start the project using Maven
mvn compile exec:java

You should see an output similar to the following confirming that the server has successfully started:

console
Console Output
Started server on http://localhost:3000/

Unless you change the APP_PORT setting in application.properties, the server will listen on http://localhost:3000 which you can now open and browse around the app. You can change which port the server listens on by editing the APP_PORT variable in application.properties and restarting the process.

A Brief Tour of the Project

If you open up the listening address in your browser, you will see a Single Page Application (SPA) that communicates with the API served at http://localhost:3000/api/movies. Currently, the responses are hardcoded, but as you progress through the course, you will learn how to query Neo4j to find this information.

Here are some of the important directories in the project:

  • src/main/java/example/ - Example code for driver instantiation.

  • src/main/java/neoflix - The application code:

    • src/main/java/neoflix/routes/ - Route handlers that are registered on the server. You shouldn’t need to edit these files.

    • src/main/java/neoflix/services/ - Services that you will need to update to interact with Neo4j.

  • src/test/java/neoflix - Test files that will you will need to run in order to pass the test. You will run these using the mvn test or individually with the
    mvn test -Dtest=neoflix._0x_XxxTest#methodName command.

  • src/main/resources/public/ - Minified build files for the Web application. Do not edit these files.

Done!

Once you have the project up and running, click the button below to complete this lesson.

Next Steps

Now that we have the project up and running, let’s take a look at the Neo4j Sandbox instance that has been created as part of your enrollment in this course.