Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ Maven "Error: Invalid or corrupt jarfile"

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?

like image 597
BullyWiiPlaza Avatar asked Sep 18 '15 14:09

BullyWiiPlaza


1 Answers

  1. Go to Module Settings --> Artifacts
  2. Create a new folder called META-INF enter image description here
  3. Add the MANIFEST file which should be located in your src folder enter image description here

as a file

enter image description here

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

like image 150
Marian Klühspies Avatar answered Oct 19 '22 19:10

Marian Klühspies