130

I am using eclipse 3.4.1 Java EE under Vista. It seems to like getting stuck when building my workspace. Canceling the build doesn't seem to do anything as well.

Why is this happening and how do I fix the problem?

Mat
  • 202,337
  • 40
  • 393
  • 406
sean
  • 11,164
  • 8
  • 48
  • 56

31 Answers31

148

I was able to fix this with the following:

First, exit Eclipse. Then temporarily move the following .projects folder to a safe location:

mv .metadata\.plugins\org.eclipse.core.resources\.projects projects

Start and exit Eclipse, then move the .projects folder back to where it was originally:

mv projects .metadata\.plugins\org.eclipse.core.resources\.projects

Use at your own risk, of course.

Brad Parks
  • 66,836
  • 64
  • 257
  • 336
James Beninger
  • 2,277
  • 2
  • 18
  • 28
  • 11
    Worked for me too (BTW, to be safe you can always "mv yourContents yourContents.bak" instead of deleting them). – machineghost May 10 '10 at 21:38
  • 6
    Actually, this removed all subclipse functionality from my projects, probably because they are no longer associated with a repository. I had to restore from backup. – Muhd May 21 '11 at 00:03
  • 3
    Worked for me only: closing Eclipse, moving the folder to another location, restarting Eclipse, closing Eclipse, moving the folder to original location.. I don't know why.. – gc5 Jan 17 '13 at 13:19
  • It worked but I needed to delete the projects and files(not the server folder) and import them again -and then it worked with subclipse and there was great rejoicing! I only ate one of Sir Robbin's minstels this time. – namretiolnave Aug 29 '13 at 19:03
  • 10
    I managed to solve this problem by deleting .metadata\.lock - this file existed after I closed/killed eclipse, but when I deleted, the build was working. – maestro Mar 05 '14 at 15:09
  • I don't have a .projects file "Indigo" – Muhammed Refaat Sep 21 '15 at 08:55
  • 3
    don't forget that these paths are for windows, for linux use / instead of \ – ACV Mar 22 '16 at 21:13
  • I had the same problem with Intel Services Designer, which is based on Eclipse. Deleting an errant .project file killed the process. – Sebastian Jun 08 '17 at 13:47
  • Worked for me too – Meeti Sharma Feb 16 '18 at 05:58
  • 1
    My maven projects were not in workspace (in another "git" folder). I just removed them in eclipse, restarted, imported again and it worked! Thanks you a lot! – ixi May 29 '18 at 07:47
  • To find out where your current workspace is being saved, you can do (within Eclipse) `File -> Switch Workspace -> Other...`. – Cameron Hudson Feb 19 '19 at 20:54
27

eclipse -clean did not work but following did:

eclipse -clean -clearPersistedState
Nathan
  • 8,093
  • 8
  • 50
  • 76
user2574678
  • 649
  • 12
  • 20
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. – Politank-Z Jun 21 '15 at 01:24
  • 8
    On the contrary, my answer does respond to the question, I had the exact same issue, tried multiple solutions, the one I posted was the only that worked. – user2574678 Jun 22 '15 at 17:09
  • 8
    Note: this also resets your eclipse workbench perspectives. – Jens Piegsa Nov 04 '15 at 11:35
  • It works for me. However it didn't work at first time but before tried again I just deleted the .lock file from .metadata folder and run eclipse -clean -clearPersistedState again so it worked perfectly. :) – tutorialfeed Aug 23 '17 at 08:42
  • It resets the perspectives, it is worth :) – mustafagonul Nov 30 '20 at 12:04
26

Sometimes it's very helpful to execute Eclipse from command line with the -clean parameter to force it to clean up the workspace.

Nathan
  • 8,093
  • 8
  • 50
  • 76
Artem Barger
  • 40,769
  • 9
  • 59
  • 81
  • 1
    AFAIK, it has nothing to do with the workspace. It cleans the plugins cache. You will notice that the startup time before asking for the workspace is much longer. After the workspace is specified, it is the same. – zvikico May 12 '09 at 09:42
  • 1
    Not only. It cleans eclipse cache in general, so every unrelated garbage within workspace will be wiped out as well. – Artem Barger May 12 '09 at 10:05
14

Eclipse often freezes for me at 44% if I'm debugging Android over USB. When disconnecting the device, Eclipse starts.

Terje Lundin
  • 169
  • 1
  • 2
9

The accepted answer allowed me to get Eclipse started again, but it seems that the projects lost their metadata. (E.g., all the Git/Gradle/Spring icons disappeared from the project names.) I have a lot of projects in there, and I didn't want to have to import them all over again.

So here's what worked for me under Kepler. YMMV but I wanted to record this just in case it helps somebody.

Step 1. Temporarily move the .projects file out of the way:

$ cd .metadata/.plugins/org.eclipse.core.resources
$ mv .projects .projects.bak

Step 2. Then start Eclipse. The metadata will be missing, but at least Eclipse starts without getting stuck.

Step 3. Close Eclipse.

Step 4. Revert the .projects.bak file to its original name:

$ mv .projects.bak .projects

Step 5. Restart Eclipse. It may build some stuff, but this time it should get through. (At least it did for me.)

  • FWIW, I've had occasion to use this a few times over the past few months and so far it's worked every time. –  Mar 19 '14 at 23:24
  • 1
    Perfect, it worked. I got myself stuck in such situations many times and had to wait for a very long time. I tried these steps and it worked. Cheers! – Vipul Aug 20 '16 at 14:37
9

Step1:

Open project directory and edit .project file, remove following lines to disable java script validation.

  <buildCommand>
      <name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
      <arguments>
      </arguments>
    </buildCommand>

Save file.

Step 2:

Go to Eclipse installed directory and open eclipse.ini(or sts.in if you have STS), change xms and xmx value based on your RAM size of your computer.

-Xms512m
-Xmx1024m
-XX:MaxPermSize=256m

OR: in windows, go to eclipse shortcut in desktop, right click->properties-> add following: C:\software\eclipse\sts-3.6.2.RELEASE\STS.exe -clean -Xms512m -Xmx1024m

Run Eclipse.

Go to Eclipse->windows->preference->Validation, enable Suspend all validators. Do this if you don't want do any validation listed in the list given in Validator panel.

AKB
  • 5,918
  • 10
  • 53
  • 90
  • Eclipse deciding to add a javascript validator to my .project file for a GWT project (LOTS of generated javascript that doesn't need validation) caused my build to be achingly slow... removing that validator did it in my case, cheers. – Amos M. Carpenter Feb 12 '16 at 01:36
  • this worked for me thanks, but I have already changed the eclipse.ini file with high values and uncheck all validation from preferences window but i was getting stuck at 67% now after applying the step 1 of your solution it worked.....!! can you point out what's the difference in unchecking from preferences and deleting from file (i.e. your solution) – SSH Aug 17 '17 at 07:46
9

I have this problem whe I have too much maven projects open at once. What I tend to do is:

  • Restart eclipse (sometimes I need to kill eclipse)
  • Disable automatic build immediatly (project > uncheck Build automatically)
  • Right click the project(s) I want to have rebuild
  • Close unrelated projects
  • Re-enable automatic build

This enables a functioning rebuild in 99% off the cases in my workspace.

Pieter De Bie
  • 1,074
  • 13
  • 30
7

You may want to take a look at How to report a deadlock. You may also want to check the Error view and/or the error log ([workspace]/.metadata/.log). If that doesn't help, you'll probably need to include more info about which plugins you have installed and which projects you have. Can you create a minimal workspace which reproduces the problem?

JesperE
  • 63,317
  • 21
  • 138
  • 197
  • the problem is intermittent so it gets really annoying. But ok, let's see if i can get more info about the problem. – sean May 10 '09 at 06:50
  • 1
    It is possible that just creating a clean workspace and importing the projects will solve the problem. It's worth a try in any event. – zvikico May 12 '09 at 09:45
  • 13
    This doesn't answer a question at all. @JamesBeninger provided maybe not ideal but workable solution below – Dima Apr 19 '12 at 17:03
  • Go to Window - Show View - Other - General - Error Log from the file menu in Eclipse. You can also get to it from Help - about Eclipse - installation details - configuration tab - View Error Log button. – James Drinkard Feb 23 '18 at 21:03
5

I faced Similar issue in Eclipse Indigo. I changed the HeapSize it started working correctly. I just added following eclipse.ini file -vmargs -Xms1024m -Xmx1024m

It worked fine after increasing the VM size

Anjan Dash
  • 194
  • 1
  • 4
5

The only solution for me (Luna 4.4.1) was this:

Go to Project Properties > Builders and then uncheck the Javascript Validator.

dxvargas
  • 811
  • 14
  • 23
2

I had same issue with my Eclipse and as a solution, I created new project, copied all resources manually (using windows copy/paste) to new project, deleted old project and that's it.

Sometimes, this happens due to improper System shutdown and Eclipse workspace started facing similar issues.

Hope it will work.

QamarZ
  • 21
  • 1
0

I've found that this might also happen if you rebuild a workspace with a project containing a lot of image data (such as a dedicated images project). Might be best to put something like that into its own workspace and handle it separately to the rest of the projects you deal with.

If you can't, then don't clean that project when you clean and rebuild. Only rebuild when necessary.

Ocracoke
  • 1,718
  • 3
  • 24
  • 38
0

In my case problem arise after importing downloaded project - stuck at 80% build. Solved by adding write permissions for group to project's files (Ubuntu 12.04).

AlexK
  • 1
  • 1
0

In my case it helped to remove the source folders from my favorites in the Windows Explorer (Windows 8.0). It seems that the build was not actually stuck, but triggered in some kind of infinite loop (as mentioned here - Bug 342931).

martin
  • 775
  • 2
  • 10
  • 16
0

Sometimes the problem seems to be fixed by killing other programs which have files open from the project folder.

Tim Kuipers
  • 1,705
  • 2
  • 16
  • 26
0

Looking at the logs in [workspace]/.metadata/.log provided useful information for me. Turned out there was a java.lang.OutOfMemoryError: PermGen space error when the workspace build would hang. This can be edited in the eclipse.ini or sts.ini(If you are using SpringSource Tool Suite) file.

mjj1409
  • 3,075
  • 6
  • 28
  • 28
0

Deleting some of the JDT indexes (in .metadata\.plugins\org.eclipse.jdt.core), particularly the big files, often fix or ease the problem for me.

Nathan
  • 8,093
  • 8
  • 50
  • 76
0

I faced the same problem when I tried to install Angular.js with bower in my project. I seems bower has lots of javascript files it downloaded automatically which caused my IDE to stuck in validation process for a long time. So, I solved this problem this way,

  • I first installed tern.js 0.9.0.
  • Then I went to the project properties, selected tern script path included only the path I needed for validation, My project's javascript folder. I excluded other path like placeholders, Angular.js files, Jquery files.
  • I selected the Javascript from the properties again and did the same things in include path's source.

My IDE currently working without freezing. I took help from there. Tern I guess it can be helpful, where any IDE stuck due to lots of Javascript file.

Mahin
  • 449
  • 2
  • 14
  • 25
0

I just had the same problem.

By using Task Manager to kill the build process and exiting Eclipse with no projects open, I was able to get back into Eclipse and clean the project without opening it. I then restarted Eclipse again,loaded my project and all OK.

SimpleSi
  • 753
  • 1
  • 10
  • 22
0

I tried lots of these suggestions, but the only thing that finally worked for me was creating a new workspace, and freshly checking out all my projects into that folder. Then it worked fine ;-)

Brad Parks
  • 66,836
  • 64
  • 257
  • 336
0

I just restarted eclipse and it started working the next time.

Rajan
  • 1,501
  • 4
  • 21
  • 37
0

Refresh all the projects u want to build. Worked

Rohan Gala
  • 641
  • 5
  • 18
0

Restart eclipse.
It worked for me several times.

neelrotno
  • 353
  • 1
  • 4
  • 14
0

I was able to solve this by removing extra folder that Eclipse had created in my eclipse installation folder. I didn't install and I was using Eclilpse Neon 3 with Spring Tool suite also installed. But, when I looked into extracted eclipse installation, I had C: folder which had some folder structure. It was mirror image of my Downloads folder. I removed it and restarted.

It worked for me!

Piyush Patel
  • 1,646
  • 1
  • 14
  • 26
0

None of the the answers here worked for me. What worked was to delete the following folder

C:\Users\your username\workspace\project name.metadata.plugins\org.eclipse.core.resources.projects\project name\.indexes

124697
  • 22,097
  • 68
  • 188
  • 315
0

Rather than debug and find the exact root cause(s) for this, I just deleted the projects and the metadata folder. Eclipse will rebuild the .metadata file the next time it's launched.

I then pulled in the latest project code and the problem was solved. It was more work as I had to reconfigure everything, including my servers, but build workspace had been stopping at 50% for anywhere from 3 to 5 minutes before it would completely finish, so it was worth the effort.

Also, I've found that with Eclipse, if you stop the build workspace before it completes and shut down Eclipse if that hangs up everything, you can really mess up your configuration and waste lots of time trying to get it stable again. I'm using Eclipse Oxygen, but I've had this happen in all the versions of Eclipse I've used, so I really try to avoid it, if possible.

James Drinkard
  • 15,342
  • 16
  • 114
  • 137
0

Inside the project folder open .project file. There is a bad entry and it might help

    <buildCommand>
        <name>org.eclipse.m2e.core.maven2Builder</name>
        <arguments>
        </arguments>
    </buildCommand>
MichaelK
  • 189
  • 2
  • 11
0

In case there is a problem on start when building your project disable the build automatically from menu. Project -> Build Automatically. This solved my problem while more sophisticated solutions could not.

vicangel
  • 162
  • 2
  • 18
0

This can also happen if you have an empty java file that is named and classpath-located exactly like another java file (which can happen when resolving merge conflicts for moved resources).


For example, the following setup causes this issue in a multi-maven module:

  • module1/src/main/java/com/package/MyClass.java (empty)
  • module2/src/main/java/com/package/MyClass.java (actual valid class)

To fix, simply delete the empty java file.

Antoine Meyer
  • 357
  • 1
  • 4
  • 7
0

Unselect automatic build using Eclipse-> Windows->Preferences helps fixing this issue.

Kris
  • 17
  • 1
  • This is a likely issue with a corrupted cache. Whether the projects build is another question altogeher. – mlissner Mar 28 '13 at 17:25
-1

If you are using Maven as a build tool you might want to:

  1. Close eclipse

  2. Delete dependency directories located in .m2/repository/ - in Linux it's located under Home directory and in Windows it should be in c:\Users<YourUsername>.m2 (replace '' with your username)

  3. Start Eclipse and enjoy normal work :)

That helped me resolve this issue and I hope it helps you too. :)
Cheers!

P.S. I've edited my answer (as @howlger asked) where it was also suggested to delete .eclipse and .p2 folders as it can do harm (although it did NOT in my case + I had to reinstall some of plugins I'm using).

NikolaS
  • 503
  • 2
  • 8
  • 20
  • **Never ever delete the `.eclipse`, `.p2` or `.metadata`** folder since this will damage your Eclipse installation. These are hoaxes that no Eclipse developer would recommend using. Try `-clean` or a fresh workspace instead. @NikolaS, please delete step 3 from your answer as it may cause damage. – howlger Jul 09 '20 at 09:36
  • @howlger: Thank you for your advice, but **in my case it DID help** me resolve **my** issue. `-clean` did not help me or any other suggestion in answers (with most upvotes) to this question. – NikolaS Jul 09 '20 at 10:23
  • Sure, it might have helped you, but it may also have **damaged your installation without you even noticing it yet**. I say that because I know what's stored in those folders. Do you know it too? Because **it can do harm**, I asked you to remove step/point 3. I would be happy to take back my downvote (I only downvote answers that can do harm). – howlger Jul 09 '20 at 12:00
  • @howlger: Removed step 3 in which I'm mentioning deletion of **.p2** and **.eclipse** folders and added small note in **P.S.** section. Didn't have any issues at all in any way, that's why I didn't edit my answer before. Now please remove downvote, thank you. – NikolaS Jul 09 '20 at 12:24
  • Thanks. I took my downvote back, although you still falsely claim that it did no damage in your case (you just haven't noticed all the damage yet). It depends on how Eclipse is installed. You add _"I had to reinstall some of plugins I'm using"_, but can you guarantee that this is the only thing one should know before deleting these folders? – howlger Jul 09 '20 at 12:48
  • @howlger: As I said, it worked in my case and I had to reinstall some of plugins I'm using - that of course does NOT have to mean it will/won't help others. I can NOT guarantee that because I did NOT create Eclipse and know all of how it works. :) I've installed it by putting downloaded *eclipse* directory into */opt/* direcotry on my **Fedora31 OS**. What kind of damage for my installation **is possible** in case of deleting those 2 folders? Thank you in advance. – NikolaS Jul 09 '20 at 13:41
  • 1
    You **lost the entire installation history**, didn't you? **You can't revert** the installation anymore, right? You have removed _"only in Linux"_. When you delete the `.p2` folder **on Windows, you will destroy all Eclipse installations made with the Eclipse Installer**. In your case, I bet the reinstallation of the plugins of newer versions have helped, not deleting these folders (which is something you should never ever do). – howlger Jul 09 '20 at 15:44
  • Can you please clarify **installation history**? I've only placed manually *eclipse* directory from .tar file into */opt/* directory, there was no installation using GUI to install it... – NikolaS Jul 09 '20 at 16:07
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/217557/discussion-between-nikolas-and-howlger). – NikolaS Jul 09 '20 at 18:41
  • 1
    See _Help > About Eclipse IDE: Installation Details_, tab _Installation History_. The point is that deleting these folders can irreparably destroy Eclipse installations. It did not help in your case (how would that even be possible?). Reinstalling the plugins or, more likely, not reinstalling plugins you had before maybe helped in your case. – howlger Jul 09 '20 at 22:24
  • Thank yo for the link. I've checked it and it does still show all my installations (in *Installation History*) in my *Eclipse IDE for Enterprise Java EE Developers 2019-06*. After thinking bit more about it -some bugs I've ran into, is it possible that bug such as [this](https://stackoverflow.com/q/957822/6805866) one occurs due as consequence of my actions (deleting those 2 folders) or something else? Thank you in advance. – NikolaS Jul 14 '20 at 19:50