0

used spring-boot-maven-plugin to build my jar, i'm to run it via

java -jar  myExample-1.0-SNAPSHOT.jar

but it throw error

Error: Could not find or load main class com.manish.myexample.Example

while running via

java -cp  myExample-1.0-SNAPSHOT.jar com.manish.myexample.Example

is because of spring-boot-maven-plugin ? and even tried

java -cp  libs/myExample-1.0-SNAPSHOT.jar: BOOT-INF.classes.com.manish.myexample.Example
Manish Jaiswal
  • 442
  • 5
  • 19

1 Answers1

0

You must ensure that you add the location of your .class file to your classpath. That is usually first mistake.

...and some general reasons why Java cannot find the class:

  1. you made a mistake with the classname argument;
  2. the application's classpath is incorrectly specified: the wrong directory is on the classpath, the subdirectory path doesn't match or dependencies missing from the classpath;
  3. the class has been declared in the wrong package.
Andreea Craciun
  • 302
  • 1
  • 6
  • have checked all except setting class-path , maven-assembly-plugin and spring-boot-maven-plugin have different policies for building jar file – Manish Jaiswal Oct 06 '17 at 13:58