Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have been struggling with a very weird issue that has suddenly popped up on the latest version of Eclipse Classic (4.2.2).

Everytime I try creating or refactoring a class or subclass in any of my projects (all Java) in my Eclipse workspace I get an error 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 current classes, then undo the renaming, its totally fine, but changing a single character in the name causes this error to happen for that specific class.

I have Auto Build on, and I tried multiple times to clean and refresh every project as well as restart Eclipse entirely.

I have literally no idea how to even start figuring out how to fix this. The solutions i've found through search didn't help, so i'm hoping I might find any clues here.

like image 988
Sammy Guergachi Avatar asked Jun 17 '13 18:06

Sammy Guergachi


3 Answers

In my case, this was caused by the fact that the build output directories were owned by a different user, and Eclipse could not write into them.

like image 90
user8574877 Avatar answered Nov 08 '22 05:11

user8574877


I had the same problem and here's how I solved it in the end: It turned out that the disc space on the drive where workspace resides was full.

Silly mistake but worth checking.

like image 13
Ganesh Satpute Avatar answered Nov 08 '22 03:11

Ganesh Satpute


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

  1. Right click eclipse then running "as an Administrator"
  2. Click Project > Clean.
like image 12
Richie_b Avatar answered Nov 08 '22 04:11

Richie_b