I have the following contents in a file src/main/clojure/za/co/pb/maven_test/test.clj:
(ns za.co.pb.maven-test.test
(:gen-class))
(defn -main []
(println "Hello world!"))
I also have a POM that has the necessary dependencies on clojure -maven-plugin with compilation execution.
If I execute the command mvn package, I get the file target/maven-test-1.0-SNAPSHOT.jar, and if I look in the classes folder, I have these files in the folder target/classes/za/co/pb/maven_test:
test.classtest.cljtest__init.classtest$loading__4410__auto__.classtest$_main.class
This, as far as I know, is suitable.
However, when I run this command:
java -cp target\app-1.0-SNAPSHOT.jar za.co.pb.maven_test.test
I get this:
Exception in thread "main" java.lang.NoClassDefFoundError: clojure/lang/IFn
Caused by: java.lang.ClassNotFoundException: clojure.lang.IFn
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: za.co.pb.maven_test.test. Program will exit.
source
share