Error "MANIFEST.MF already exists in VFS" when creating new artifact - java

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.

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.

Another solution would be to just :
Navigate to $HOME$\IdeaProjects\ProjectFolder\src\META-INF and delete the MANIFEST.MF file in there.
Restart IntelliJ Idea
Go to Project Structure > Artifacts -> delete your project artifact setting
Add new artifact setting and reconfigure as required.

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 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 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.

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.

Related

Adding External jar copy to Project

I created a project but I am using an external library for it. enter link description here
I added the library to my Beans as follows:
Right click on folder "Libraries"
Add Library
Create...
Gave it a name "gson 2.7"
Picked the class, source and javadoc files.
I went on and continued programming and then I added my code to Github. Then when I cloned it my Library was missing.
How can I fix this ? How can I make it dynamic so I dont have to worry about this anymore. In other words I need to add the library to my code and not just the reference.
Thanks a lot for the help
Just upload a copy of your library to github.
I have not used netbeans, but from what I understand it adds the jar somewhere outside of your project directory, and it simply adds the location of the jar to your classpath. When you upload and then clone the project from github, the jars are not uploaded/cloned, and the project structure metadata for your project is also lost from netbeans.
My suggestion is to learn and start using a build tool like maven. It takes up the responsibility of adding your dependency libraries everytime, given that you have an internet connection. It also adds the libs to the target directory of your project folder, so you probably will need the internet connection only once. The libs will be uploaded and cloned back from the github repo everytime.
IDEs like eclipse have inbuilt support for maven, so you don't even have to worry about executing the mvn commands. Here's a tutorial that will get you intrigued - with the IDE that you prefer.
https://platform.netbeans.org/tutorials/nbm-maven-quickstart.html
Thanks a lot for all the replies and comments.
Technically there are two approaches to my problem. For this articular example I chose to copy the external jar files to my project.
1. Copy jar files to your project.
Go to project properties
Under Libraries folder make sure to set up a libraries folder by following the steps.
Add Library at the bottom ( you can create or import; since I already had gson in Netbeans I just imported it.)
Press ok to confirm and you are done!
2. Use Maven
Go to plugings and make sure you have all Maven plugins installed, if not do so.
Create an new project and choose maven/java application
Follow the prompts
At this point you can start coding (in my case I just imported my class files from the other project)
Right click in "Dependencies folder and then "Add Dependency"
Under query type the repository you are looking for; in my case "com.google.code.gson : gson : 2.7"
Click add and you are done!
Thanks a lot to everyone for the help :)

Eclipse: Issues with deleting and creating projects

I am having an issue in Eclipse. If I create a project, then delete it and check the "Delete project contents on disk (cannot be undone)" check box, a project created afterwards with the exact same name and settings will not be created with a MainActivity.java file.
If I create a project then delete it without checking that box, it can be recreated with the MainActivity.java file but will require you to open and save the fragment_main XML file before the project can be deleted again (with or without checking the check box).
What is happening here? Why does it behave in this way?
#Zach H
When deleting a project give you two options(The dialog box will ask your confirmation for deleting from workspace or not)
Simple Delete
Delete from workspace
Under simple delete-
As you delete a project then the project gets deleted in the Package Explorer but is still present in your workspace directory (i.e. the path where your projects are stored) because you didn't select delete from workspace option.
Under Delete from workspace-
When you confirm the option delete from workspace then you project gets deleted from your hard disk as well.
When you simply choose delete then you can create a same project with same activity because the project with same name is not there in the package explorer. Only if the same project already exists then you will get an error asking you to rename your project.
The above said problem happens only when you have not installed the ADT/Eclipse properly(missing some files from the SDK Manager).
My suggestion for you is that you first install all the packages from the tools because a missing support tool could coz such problem as above
When you delete a Eclipse project this is what happens:
If you choose delete on disk - You delete the project and the files from the PC.
If you don't choose delete on disk - You only delete the project from eclipse but the files still there, so if you create a new project with the same name them put automatically.
For this case when you need some files from old projects,
So, the best way is import or export projects.
I hope this help you.

Eclipse doesn't compile java files into classes

I have no idea why, but from today Eclipse doesn't compile .java files into .class. I press the "Run" button and Eclipse only tries to run the program rather then compiles it first, so i get this error all the time:
Exception in thread "main" java.lang.NoClassDefFoundError
open problems view from window -> show view -> problems, if there's any error, fix it
eclipse will reject to compile if there is any problems in your project
Close Project -> Open Project -> Clean -> Refresh
Hope it helps for someone else
This problem happens when "for some reasons" your project is corrupted and has a red icon near the project's name in Eclipse. The solution is to save the project's folder, delete the project in Eclipse, than create the project again in Eclipse coping all the previous files saved.
I ran into this problem with Eclipse Luna, for some reason the Java builder was missing from the project. Verify that in your .project file you have something like
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
You can also configure builders from Project Properties -> Builders
When I have had this exact same problem, its cause has always been the same and the solution has worked 100% of the time for me. It's caused by a missing jar file in the project's Java build path and it's indicated by a red exclamation point decoration on the project icon. To fix the problem, go to Project|Properties|Java Build Path, click on the Libraries tab and either remove or fix the path for all missing jar files. If your project is configured to rebuild automatically, it should start a build as soon as you apply your changes.
The eclipse needs to erase the output folder when building classes.
The folder is found on Project Properties -> Java Build Path -> Default Output Folder. It can differ from general output folder name found under Eclipse Preferences. If this output folder cannot be erased for some reason (for instance, on Windows, when a shell is opened on this location), the project is marked as corrupted (as Marco Micheli describes) and the classes then are not built.
You just need to make sure the output folder can be erased.
Yes I was facing this issue. Coz Eclipse cannot build the project for Build Path error. Check that your external jar files is not showing any error. Delete the Jar file which one is missing or which one is showing re color. delete that one. add a fresh one from the correct path or location. if all the error are gone. then in the project bin folder one class file will be created and then could not load main class error will be removed too.
there can be errors in your project, or other reasons like mentioned in above answers.
or you may be a fool like me
who moved the source code to other folder and not updated source path in project build properties. in this case it was not giving any error or class files too.
check that too.
goto
Project Properties -> Java Build Path -> Source
Add or Link new source folder location.
Do clean all projects ! This will erase all old class files, so eclipse is forced to generate them again.
Some times jars in the build path might be missing even though we are not using it. Since error is there, java files wont compile into classes.
Can check errors from problems view.
Either remove jars from build path or place the missing jars in the build path.
I had problem in eclipse for load module not found and no class file was getting created.
Solution: Go to Create New Project > Under JRE section Choose Use project Specific JRE.
Now Class files are created.
Please check if all the jars are there in your build path settings.
If any jar is missing this issue might come.
I had this problem, I tried the clean, the build manually, open, closing the project, deleting, and open, etc., nothing works, and after 4 hours I get a workaround what works for me.
Please, Make a RAR, ZIP, or copy from your entire project folder as a backup if it doesn't work and you mess around, OK, now:
Clean the Project. It cleaned all my class files from the output folder, but doesn't generate the class files after the clean with the building (but we already know that)
Delete the project (warning, make sure the Delete contents is not selected or your project will dissapear). For me it says something about that desynchronysation with code mix, and hibernate, blabla)
Close myEclipse
Restart your computer.
Open myEclipse
Import the project with the option "Projects from folder or Archive", not with the "existing projects into workspace" option.
Myeclipse start to build the class files, I don't know why, but works for me, I hope this helps somebody else.
Also ensure that there are no projects with fatal errors (projects with ! symbol over it) in the build path of the project which is not generating classes under the bin directory
Just restart your machine.
Its weird but it helps we had loads of problems this type in our company for unknown yet reason. Always restarting the machine helped.
It was normally encountered while trying to run Junit tests and it could not find a class even when the Run configuration was pointed to /bin.
I encountered a similar problem: previously compiled and running java files couldn't run anymore. Eclipse showed "couldn't find class xxxx". When I checked bin folder, the previous .class files were gone. That's why Eclipse couldn't run the files, NOT because of errors in files. I don't know why it can't just re-compile the file, and why the .class file gone missing in the first place.
But I found a solution:
Simply create a dummy java file in the same package (without doing anything just create), then run it. Then magically all previous .class files came back. And I can run those files as before.
Just Remove Your all Jars (Libraries) from the Build Path and refresh and add all jars and clean and build the project
This is probably a rare event but I declared a servlet with annotations and left off the "/" before the servlet mapping name. I spent over an hour chasing my tail, installing new servers, thinking I might even need to re-install my IDE and it was this simple error! Every time I tried to load any page from my Dynamic Web Project I got a 404 error. I could not even load a plain vanilla html page. There really needs to be better error logging with the IDE and Server interaction as there was zero indication of the error and my servlet was never called at the start of my web app. Hope this helps save someone else some frustration. Always name your servlet with a / slash like /myServlet never just myServlet.
I tried many different potential solutions: cleaning, rebuilding, removing, re importing, Update Maven Project and nothing. I still couldn't run my app from Eclipse. In my case the reason was that I was running Eclipse using openjdk-11 while my project was in Java 8. After I've reconfigured Eclipse to be ran from Java 8 everything started to work (in eclipse.ini).
-vm
/usr/lib/jvm/jdk1.8.0_202/bin
I'll explain my solution to this problem: "eclipse not compiling java files into class files". I'm using Eclipse version '2020-03 (4.15.0)'. I have a project that is dependent on a java project. For the dependent project, I was not able to export a jar file containing the compiles classes and resources. To be more precise, the exported jar file did not contain any class files. The output bin folder for the project is empty after doing a project build. In examining the console output when I tried to build all projects indicated that the build failed because the dependent project was missing. In looking at one of the log outputs, I saw something indicating that the build failed because some eclipse class was missing.
One of the things I tried was to do an eclipse update. Eclipse offered up the list of changes and I tried to apply them, but the update failed. I tried to update several times but they all failed. Looking more carefully at the offered up list of updates I noticed that one of the suggested update involved "deleting" Java Development Tools. That line had an warning indicating that the entire feature could not be deleted due to other dependencies and that only the non dependent features would be deleted. Doesn't that sound suspicious. Why was the update trying to delete Java Development Tools? My speculation is that something got deleted from the Java Development tool that was causing the build process to fail. The missing class I saw earlier also suspiciously sounds like it might be part of the Java Development Tools feature.
So what I did to solve the problem was to reinstall eclipse. I used the eclipse loader application to do the reinstall. (Note, I did not uninstall it first). After the reinstall, the dependent project was able to produce classes, and things once again worked as they should.
I certainly don't know how the eclipse release got into this compromised state, but in my situation the re-install of eclipse was the only way I could find to resolve the problem.
There would be the case : if you have opened project explorer in eclipse then it may not show you classes generated under /**/build/classes, in such case open Navigator view of that project and check build directory under the same project.

Eclipse Hell . . . Failed to read the project description file (.project)

I think Eclipse is trying to make me miserable. A couple of hours ago, my project was working and compiling well. Suddenly that all changed. Eclipse somehow wipes out all changes I have made to my files(activity, manifest etc.) I make sure to save often but when I go to run the project, I get the error that I have a build error. I checked and there was none, so I go to close Eclipse, so I can reopen and see if the errors will go away. Instead what happens is Eclipse wipes clean all my files and I end up with a project on disk with lots of blank code files. I try to run anyway, and I get the error message below.
Failed to read the project description file (.project) for 'com.example.android.nfc.simulator.FakeTagsActivity.FakeTagsActivity'. The file has been changed on disk, and it now contains invalid information. The project will not function properly until the description file is restored to a valid state.
Anyone have an idea what in the world this is about and how I can rectify this?
I would recommend to wipe out all the eclipse related configuration files(make sure you take the backup if you have manually made some changes in those) and import the project again, by following
File -> Import... -> Existing Project into Workspace
Make sure you take the backup of whole project before doing this.
When Eclipse gets stuck in some obscure status, I usually find useful to recreate the .metadata folder in workspace directory. It is a drastic solution, but it usually works for me. After that you can reimport all your projects.
This happened to me because I had a conflict in my .project file. I opened it up in a text editor and fixed the conflict (in my case, removed from ====... to >>>branch..., as well as <<<HEAD) and then I was able to open the project in eclipse.
I was just encountering this same issue (using Zend Studio 12, which is built on Eclipse). My problem was that I was creating a project from a Remote Server, and I was just downloading everything, which also included the .project file from the old project. It wasn't showing this error until I'd closed the program and tried to open it again (which usually wasn't until the next day).
I seem to have resolved it by making sure not to download the .project when initializing the project.
If the .project file is a text file, so if you have it in version control you might want to copy it over from there.
Before you trying the following make a backup of your current project state.
Assuming you don't have an old copy, you can open it in a text editor and try to see if there is something obvious wrong.
If this fails, copy the source files of your project to a fresh location (without the eclipse configuration files) and import it as a new project into eclipse.
if you still have all of your other source (.java files, AndroidManifest.xml, resources), you might be able to get your project back by simply going to the folder containing the project, removing the .project file that you say is now empty, and then using the new project wizard to recreate the project (and .project file) for you from your existing tree of source.
from the menus, select File -> New... -> Project , and then, in the first dialog, choose Android Project from Existing Code .
if you had done anything special to the .project (reliance on specific .jar files or changes to classpath), you may have to re-do these steps after you re-create your project; but at least it should pick up the code you already have.
If all the files are empty, and you have no working Backup, I can't help. I would recommend to use proper version control in the future.
Use git or mercurial, they have nice UI integrations (see tortoisegit/tortoisehg).
To decouple the build process and library management from eclipse, take a look at maven or gradle, this might help you in future projects.
If you use git, complete the merge e.g. del the head in your androidmanifest.
I also got the Same Issue in Eclipse but the real problem is i removed the actual Source project folder from source location (from which eclipse is trying to take the project) to some other place hence my eclipse is unable to get web.xml file since it is not available. Now i changed my source project folder location to the path where eclipse is trying to search for. Issue Resolved for me.
Just delete the 'servers' folder in your workspace and try again.

Problem with Java Buildpath in Eclipse

In eclipse I have an error related to my build path.
The error:
Project 'XX' is missing required library: 'middlegen-2.1.jar'
But the library is deleted before the build path configuration.
Is there perhaps a problem with cache or so?
Has anyone an idea why eclipse say that the library is required even though the library was deleted before the build path configuration.
With Best
I guess you've deleted the library from a directory, but you've not updated the project Build Path. Right click on the project name, select "Properties", go to "Java Build Path", choose the "Libraries" tab, and see that your library is not in the list. If it's still in that list, remove it with the "Remove" button.
This error is due to probably either missing required library or due to caching of eclipse
Solution 1
Open project explorer window.
Right click on the project and goto Buildpath -> ConfigureBuildPath
Under the libraries tab check whether all the used jar files are physically located in the directory/web application library.If something is showing "RED X" mark then fix them by either putting the jar in the place or remove it or add it newly using add JARs
Solution 2
1.Try cleaning the project's using Menu->Project->clean (select the projects and clean it)
Solution 3
If your build path is very clear i.e no Red "x" marks then the error could be of eclipse caching.Then do below step
1.Right click on the project choose "close project".
2.Once the project is closed again right click on the project select open project
This solution will clear the eclipse cache.
Hope any of the solution should resolve your problem.
I had this same problem, but the steps above didn't help. I did a search through files in the Eclipse workspace and found files named .markers and .markers.snap that contained the bad path names under the folders in .projects that were named for the projects that weren't building. I exited Eclipse, backed up those files, removed them from the Eclipse workspace, and restarted Eclipse. The problem went away.
Your project configuration includes a reference to middlegen-2.1.jar on the build path. That file is missing. You can either a) put the file there, b) change the configuration to point to the file in another location, or c) remove the reference, cross your fingers, and hope the project compiles and runs without the jar.
I don't know what "the library was deleted soon" means, so if that is important to your question, you might want to rephrase.

Categories

Resources