Creating Jar With Intellij 2016 - No Main Manifest Attribute


Answer :

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:




  • Run/Debug Configurations

  • MANIFEST.MF

  • in Progect Structure settings: Project, Modules (mark what is
    sources, resources and etc), Artifacts.



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



enter image description here



If using Maven, Ensure your pom.xml has the main class referenced and fully qualified, similar to:



        <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<mainClass>org.mypkg.MyMainClass</mainClass>
</manifest>
</archive>
</configuration>
</plugin>


(... of course the version number of the plugin may be different).



The main class being not fully qualified, is what leads people to suggest moving the manifest to another location (in order to satisfy the reference locally).



Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable