1

I have created a jar in path xxx/IdeaProjects/xxx/out/artifacts/abc_jar.

When I run it using java -jar, I get

Could not find or load main class ...

I have moved the mainfest file to xxx/IdeaProjects/xxx/src/main/resources/META-INF/MANIFEST.MF

and main class is com.rh.xxx.Application, but still getting

 Could not find or load main class... 
John Joe
  • 12,412
  • 16
  • 70
  • 135

1 Answers1

2

Set the Start-Class attribute value in MANIFEST.MF file with the fully qualified java class. Verify the same in the generated jar file after the jar is created.

Please refer below, here starter class is the one has main method.

Content of, META-INF/MANIFEST.MF

Main-Class: org.springframework.boot.loader.JarLauncher
Start-Class: com.mycompany.project.MyApplication

Refer https://docs.spring.io/spring-boot/docs/current/reference/html/executable-jar.html#executable-jar-launcher-manifest for more info.

Marged
  • 10,577
  • 10
  • 57
  • 99