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:
- Go to Module Settings --> Artifacts
- Create a new folder called META-INF
- 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.