I am getting no main manifest attribute
while running the jar create by Intellij. I extracted the jar and observed that there was another manifest file, not the one I had specified while creating artifact.
When I open manifest in IDE, it displays everything right but after creating jar I get a whole new manifest file.
Manifest-Version: 1.0 Main-Class: YoutubeList
I tried every solution from other answers and still not getting it right. Why creating a simple jar is hell of a task in Intellij, it was supposed to help developers!
Edited
And sometimes it does not include .class files in Jar which results in could not found or load class
Sometimes this error may be encountered in your Spring Boot project. It is easy to resolve this error in the Spring Boot project. To fix this error in the SB project, put the maven-plugin dependency under the <plugins> tag in the pom. xml file.
The answer is the JAR file's manifest. The manifest is a special file that can contain information about the files packaged in a JAR file. By tailoring this "meta" information that the manifest contains, you enable the JAR file to serve a variety of purposes.
You use the m command-line option to add custom information to the manifest during creation of a JAR file. This section describes the m option. The Jar tool automatically puts a default manifest with the pathname META-INF/MANIFEST. MF into any JAR file you create.
I was stucked with the same problem with maven build. When you are creating the artifact from project structure settings (ctrl+alt+shift+S), you have to change manifest directory:
<project folder>\src\main\java
change java to resources
<project folder>\src\main\resources
I have also used the option extract to the target JAR, and it's working well.
EDIT
You can find a detailed step-by-step, an other solutions here: https://stackoverflow.com/a/45303637/2640826
I spent a few days to resolve it. My solution: I loaded a project that present in this answer. Then I compared and corrected settings of the loaded project and my own project. I compared/corrected:
In the end, I placed META-INF in resources directory.
Maybe i did excess actions, but it worked for me :)
P.S. also need to choose "Inherit project compile output path" in Progect Structure settings -> Modules -> Path
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With