Eclipse Build Error "The class file was not written. The project may be inconsistent if you try to update this project and create it."

I struggled with a very strange problem that unexpectedly appeared in the latest version of Eclipse Classic (4.2.2).

Every time I try to create or refactor a class or subclass in any of my projects (all Java) in the Eclipse workspace, I get an error message at the very top of my class that says

A class file was not written. The project may be inconsistent, if so try refreshing this project and building it 

Again, this happens when I create new classes. And even when I rename the current classes, cancel the renaming, its completely fine, but changing one character in the name causes this error to happen for this particular class.

I have Auto Build on, and several times I tried to clean and update each project, and also completely restart Eclipse.

I have no idea how to even begin to figure out how to fix this. The solutions I found through the search did not help, so I hope I find some clues here.

+9
source share
18 answers

I had the same problem, and here is how I solved it in the end: It turned out that the space on the disk on which the workspace is located is full.

Stupid mistake, but worth checking out.

+7
source

In my case, this was because the source assembly directories belonged to another user, and Eclipse could not write them.

+5
source

Clean up your workspace by running eclipse from the command line with the -clean argument:

 eclipse -clean 

See also. How to start eclipse in pure mode? and what happens if we do this?

+3
source

We also use Eclipse and must handle the workspace with more than 200 plugins. From time to time, people run into similar issues with their workspace and the inconsistencies that Eclipse is strangely reporting. Usually people do here (the next step only if the previous step did not help): - attempt ContextMenu-> Team-> to clean / update the entire workspace - create a new workspace and check all the necessary files from the repository - reinstall Eclipse into a new one catalog

From my experience of using the Eclipse IDE on a daily basis for many years, it doesn’t make much sense to spend too much time on these problems if they are not solved by one of the above steps. It takes too much time to deal with these things, while starting from scratch in an hour or less (and usually fixes the problem). If your Eclipse is still behaving strangely, it might make sense to go through the installed plugins. Not all external plugins follow Eclipse guidelines and can seriously affect the performance and operational consistency of your Eclipse installation (e.g. Sonar Plug-in, Toad Plug-in, ...)

+1
source

In my case, such an error caused by a lack of disk space was resolved by freeing up the disk space on which eclipse is installed. These are c / d / e drivers.

+1
source

In my case, this error was caused by a question mark in the name of the quoted method (I use the combination of geb + spock for automatic testing).
So this method name throws the error "Do you want something?" ()
And it will not be "Do you want something" ()

0
source

This may not be the best answer, but to fix it I just delete the error marker.

0
source

There was the same problem. but cleaning up the project and restarting eclipse did not help, and disk space was not a problem. After solving the problem, copy the code to notepad (just so as not to lose it), and then delete the class, recreate it and paste the code again.

0
source

I decided that this changed the ownership of the project files. I changed from root (old owner) to my current user (the user I use with eclipse).

0
source

Just modified and saved the Java file to recompile the class. Then the error disappeared.

0
source

I had the same problem on Mac OS X. I had a Maven project.

Try the following command in the terminal. This seems like an access issue.

 sudo mvn clean 

Provide a password for the administrator.

Then open Eclipse and update your project.

0
source

I get the same error, and in my case, this is because the resolution of the project/bin not recursive 775

I fixed this:

  1. Delete the project/bin : sudo rm -rf project/bin
  2. Switch to Eclipse, rebuild the project: Project->Clean...

Then there are no mistakes.

0
source

I tried to run

Project-> Clean ...

And recover. My problem has been resolved

0
source

For Linux (Debia) and work on the Spring (Maven) boot project:

 $ sudo mvn clean 

Then open Eclipse and File -> Update.

0
source

I had the same problems, the following worked for me:

  1. Right-click on eclipse, then run "as administrator".
  2. Click Project> Clear.
0
source

I had the same problem, it is something similar, but this post did not help in my case. I have many inner classes, as a result of which the compiler creates class names along with all the inner class names, which creates a file name limit of more than 255 characters in NTFS! read it on some other blog. I thought it would be useful to post here.

Example: classA $ InnerClassB $ ...... InncerClassZ.class in the target folder will not generate a class if it exceeds this limit. Try renaming your internal class name to abbreviated. In my case, I have to add InnerclassZ as it is superior to its non-generating class and complains about Eclipse.

The class file was not written. The project may be controversial, if so, try updating ....

I abbreviated InnerClassZ so that IClassZ fixes the problem.

0
source

I solved this problem by running Eclipse as root.

0
source

Before giving a try the above solutions. I just cleaned the project and it worked.

-one
source

All Articles