Java quick start
At the end of this guide, you will have created a simple Java console Hello, World!
program that connects to the Memgraph database and executes simple queries.
#
PrerequisitesFor this guide you will need:
- A running Memgraph instance. If you need to setup Memgraph, take a look at the Installation guide.
- A basic understanding of graph databases and the property graph model.
- Java 8 or 11 installed.
#
Basic SetupWe'll be using Eclipse IDE 2020-09 on Windows 10 to connect a simple Java console application to a running Memgraph instance using Maven.
If you're using a different IDE, the steps might be slightly different, but the code is probably the same or very similar.
Let's jump in and connect a simple program to Memgraph.
1. Open Eclipse and create a new Maven project.
2. Select the Create a simple project option.
3. For the Group Id field put com.memgraph.app
and for Artifact Id put my-app
. Afterwards, click the Finish button.
4. Open the pom.xml
file and add the following dependency:
5. Create the HelloWorld.java
program and copy the following code:
Once you run the program, you should see an output similar to the following:
#
Where to next?For real-world examples of how to use Memgraph, we suggest you take a look at the Tutorials page. You can also browse through the Database functionalities section to get an overview of all the functionalities Memgraph offers.
#
Getting helpVisit the Getting help page in case you run into any kind of problem or you have additional questions.