I'm a newbie to Java (just two days) and am trying to get an HTTP server running using Spark. I created a new Maven project in IntelliJ and have a Hello World response coming back from Spark when running it in IntelliJ. As a learning exercise, I would like to get the app running from the command line using Java.exe. When I run java Main
, I get the following error:
Exception in thread "main" java.lang.BootstrapMethodError: java.lang.NoClassDef oundError: spark/Request at Main.main(Main.java:5) Caused by: java.lang.NoClassDefFoundError: spark/Request ... 1 more Caused by: java.lang.ClassNotFoundException: spark.Request at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 1 more
Looks like it can't find the Spark .jar files. There's a command line option -cp
to specify paths to dependencies. After looking up where Maven keeps these files, I tried running:
java -cp .;C:\Users\jbuschmann.m2\repository Main
Still same error. How do I specify the path to the Maven dependencies?