Search code examples
javaclassnotfoundexceptionexec-maven-plugin

Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default-cli) on project <project-name>:


When I build a jar file using maven build and try running it from command line. I am getting this error.

    java.lang.ClassNotFoundException: <className>
        at java.net.URLClassLoader.findClass (URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass (ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass (ClassLoader.java:357)
        at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:270)
        at java.lang.Thread.run (Thread.java:748)

Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default-cli) on project <project-name>:An exception occured while executing the Java class. <class-name> 

Tried everything I saw in Stack Overflow and Github but the problem is not resolved


Solution

  • Finally got it working...

    Had to add the classes folder(from the target folder) in the folder where I pasted the .jar file.