IntelliJ Maven “Error: Invalid or corrupt jarfile”

匿名 (未验证) 提交于 2019-12-03 02:56:01

问题:

I'm using IntelliJ to develop Java Desktop applications. On my project, I added framework support for Maven and added a dependency to the pom.xml file. I also added a build artifact like described here (I would also appreciate if this question gets answered). Now that my project has Maven support, the generated JAR file no longer works. When I try to launch it, it displays the error Error: Invalid or corrupt jarfile MyProject.jar. When I open the JAR file using WinRAR, there is no MANIFEST.MF file included, only folders and CLASS files. What happened to my Maven dependencies as well? Why does IntelliJ not properly build my Maven project into an executable JAR file via its artifacts?

回答1:

  1. Go to Module Settings --> Artifacts
  2. Create a new folder called META-INF

  3. Add the MANIFEST file which should be located in your src folder

as a file

This will tell IntelliJ to copy the manifest into the jar file.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!