Error in neo4j java driver

Hello,

I copied the example on: Overview (Neo4j Java Driver 5.2 API).
After compiling SmallExample.java 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.(SmallExample.java:12)
at SmallExample.main(SmallExample.java:56)
Caused by: java.lang.ClassNotFoundException: org.neo4j.driver.AuthTokens
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 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 https://mvnrepository.com/artifact/org.neo4j.driver/neo4j-java-driver/4.0.1.

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

<dependency>
  <groupId>org.neo4j.driver</groupId>
  <artifactId>neo4j-java-driver</artifactId>
  <version>4.0.1</version>
</dependency>

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.