[英]“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.我正在处理一个我想作为 jar 执行的 kotlin 项目。 This is all done in IntelliJ Idea and I went about making the jar using the artifacts.这一切都是在 IntelliJ Idea 中完成的,我开始使用工件制作罐子。
The process I followed was (as illustrated by an Idea guide):我遵循的过程是(如创意指南所示):
After this, I get a在此之后,我得到一个
'no main manifest attribute, in ____.jar'
What I have tried after reading several stack overflow questions:在阅读了几个堆栈溢出问题后,我尝试了什么:
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不确定这是否是“真正的”问题,但我也不知道如何解决这个问题
For anyone that may have encountered this problem in intellij and did not find a solution in any other posts, what helped me was对于可能在 intellij 中遇到过这个问题并且在任何其他帖子中没有找到解决方案的人,对我有帮助的是
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 ") Meta-inf: (...)\\src\\main\\
(你必须删除“ 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!仅此而已!
在创建可执行的 jar 文件时,显式地创建一个 mainfest.txt 文件,该文件应该按照目录结构的顺序,mainfest.txt 文件应该只包含一行(Main-Class:包含 main 方法的类的名称)然后运行 jar 工具
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.