Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"no main manifest attribute" error in intellij when executing jar

I'm working on a kotlin project that I want to execute as a jar. This is all done in IntelliJ Idea and I went about making the jar using the artifacts.

The process I followed was (as illustrated by an Idea guide):

  1. Add artifact (as jar) from project structure
  2. Build jar
  3. Run jar

After this, I get a

'no main manifest attribute, in ____.jar'

What I have tried after reading several stack overflow questions:

  • Checking that the manifest file is in the correct folder and has the correct path in the artifact
  • Adding code to the build.gradle file for the jar->manifest portion
  • Trying the method of moving the manifest stuff into a resources folder
  • Checking that the jar exists
  • Moving the manifest stuff into a different folder (java,kotlin,out folders)
  • Making sure that the manifest file is in the correct format

All of the above has not worked.

Something that is confusing to me is that, even when I alter the manifest file to be in "incorrect" format, it still gives the same error. The path stated in the artifact's details is correct yet there is no difference even when I purposely input incorrect items in the manifest file. Not sure if that is the"real" problem but I'm also not sure how to fix that as well

like image 202
lacanlale Avatar asked Jan 08 '18 03:01

lacanlale


People also ask

How do I specify JAR manifest?

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.


1 Answers

None of the solutions worked for me.

I solved it in this way:
When setting up the artifact, change:
Meta-inf: (...)\src\main\ (you must remove "java")

Also, there was a problem with resources, solved this way:
When setting up the artifact:
Output Layout > Add copy of > Directory content > resources.

That's all!

like image 116
Robot Avatar answered Oct 16 '22 23:10

Robot