Error in neo4j java driver


I copied the example on: Overview (Neo4j Java Driver 5.2 API).
After compiling into a jar-file and running it from the command line with:
java -cp name_jar_file.jar SmallExample

I get the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: org/neo4j/driver/AuthTokens
at SmallExample.(
at SmallExample.main(
Caused by: java.lang.ClassNotFoundException: org.neo4j.driver.AuthTokens
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(
at java.base/java.lang.ClassLoader.loadClass(
... 2 more

I have an active database running through Neo4j Deskop and the username and password are correctly altered in the original example.
Can someone point out what I'm doing wrong? Thanks!

you need to have the neo4j-java-driver jar file on your classpath in addition to your code, see

Isnt that taken care of by the pom-file automatically? I have declared it as a dependency there:


For build time yes. If you want to bundle the neo4j-java-driver jar into your application's jar file, you need to Apache Maven Shade Plugin – Introduction or something similar.