35

I have a Java project that I used to be able to build artifacts from, but now I am unable to.

First, my project was building and I was able to create artifacts, but on running the .jar I was getting "Java Exemption Error". I checked to see what version of the compiler I was using (1.8) and made sure my machine was up to date.

Next I tried to fix any dependency issues by deleting and re-associating some of my external .jar files.

Then I deleted the artifact setting and tried to create a new one. Now I receive a

.../MANIFEST.MF already exists in VFS

error when trying to create a new artifact.

I'm using the latest version of Intellij. My source code can be found here: https://github.com/mjtik/PiccoApp.

I can provide screen shots if necessary.

*I have created many .jars in the past, not sure what changed in my project.

Any suggestions or guidance would be appreciated.

Bond
  • 16,071
  • 6
  • 30
  • 53
mjtik
  • 839
  • 1
  • 7
  • 6

4 Answers4

48

I solved my problem. Ever step I took lead me to the solution. The problem was with how I was creating the new artifact.

When creating the new artifact, I selected JAR and then a popup window displays default settings. It has me app module selected and the main class below is blank.

I was selecting the main class and it was producing an error. When I just accepted the default options left the main class blank, the artifact was created.

mjtik
  • 839
  • 1
  • 7
  • 6
  • I'd expect it to overwrite the manifest if a main class is selected. – kmiklas Feb 05 '21 at 22:32
  • just one line : create an artifact with jar > with module dependency , and leave the main class blank, - oh! how it is possible, I can never think that way, cleverer solution ! – Noor Hossain Oct 06 '21 at 14:05
37

Another solution would be to just :

  1. Navigate to $HOME$\IdeaProjects\ProjectFolder\src\META-INF and delete the MANIFEST.MF file in there.
  2. Restart IntelliJ Idea
  3. Go to Project Structure > Artifacts -> delete your project artifact setting
  4. Add new artifact setting and reconfigure as required.
The-Droidster
  • 635
  • 7
  • 13
  • 4
    I tried removing the META-INF folder itself and it worked for me without restarting IntelliJ – Midhun Agnihotram Oct 26 '16 at 07:53
  • 1
    Great job! The **key** step is: **delete folder first, then delete artifact**. :P – MewX Jan 06 '17 at 08:08
  • 1
    I think the key is to let IntelliJ detect file system changes after you deleted the file. As long as the project structure (or other dialog) is open, or if the main window is not active, it won't detect changes. – Mark Jeronimus Nov 24 '17 at 12:13
20

I inherited a project which already had the MANIFEST.MF file in the META-INF folder in the src folder. But this project did not have a artifact configured in the project structure dialog box. I also don't think that deleting an existing file and restarting Idea is an ideal solution for this problem.

I've listed below the steps that worked for me and these were done on Intellij Idea 2016.1.

Step 1: Choose Empty when you want to add an artifact to create a JAR file with an existing MANIFEST.MF file. Do NOT select From module with dependencies as that will lead to the error described in the question.

Step 1

Step 2: In the next screen, select the Use Existing Manifest button to navigate to and select the existing MANIFEST.MFfile. Make any other changes you need now so the JAR artifact is created per your needs.

Step 2

Step 3: Select OK and you should be all set now. Depending on whether you selected build on make and make your project or if you specifically generate the artifact, your JAR would get created without any issues.

Step 3

Karthic Raghupathi
  • 2,011
  • 5
  • 41
  • 57
5

I use "create artifact from modules". If I get the notification for the manifest that exists, I delete the manifest file, then do "invalidate caches and restart". I think Intellij is complaining about a copy of that file that's in the cache.

Christine
  • 5,617
  • 4
  • 38
  • 61