John Joe
John Joe

Reputation: 12803

Failed to generate JAR file using Intellij

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... 

Upvotes: 1

Views: 553

Answers (1)

Anil Kumar Athuluri
Anil Kumar Athuluri

Reputation: 653

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.

Upvotes: 2

Related Questions