Eclipse only seems to compile once per opening...

Alright, so I got this problem where eclipse only compiles a project once per opening of eclipse. I think maybe it has something to do with eclipse not knowing where my jre/jdk is? I tried uninstalling both java, and eclipse, and it’s still doing it. Anyone know how to fix this? Or at least how to point eclipse to my jre/jdk?

I’ll go for the obvious:

Is Project -> Build Automatically checked?

Or can you look in your problems list and see anything about “Build Path Incomplete” or “Something missing on Build Path” or “Unable to build project, please fix …”. The problems list is a view you’ll want to open from the view menu. But avm1979’s advice is also a likely solution (but it wouldn’t have unchecked itself so if that’s the problem, you did it to yourself).

It seemed to be cause I wasn’t saving before I built?

Yes, if the file is not saved then it is in RAM, not on the disk. And the files on the disk are the ones that are compiled.

But I think it use to auto-save when I built projects. :frowning:

Start treating Ctrl+S as the compile shortcut :wink:

Select project, then Project > Properties, ensure that Builders has Java Builder selected and Java Build Path has the right JRE. Maybe a conflict between multiple JREs installed o.O?!

Do Start > type “cmd”, > type “java -version” to see which version of java you got on the path. Remove all but this one from your Java Build Path. Any luck ??? ?

Minor correction. Effectively this is what you see, but not what happens under-the-hood.

What exactly happens under-the-hood?

Eclipse has it’s own compiler builtin. So when you save, it basically signals to update the source and bytecode files on the filesystem. As you type the frontend part works incrementally updating an intermediate representation (IR), which gives you all of the syntax & error checking. I’m not sure when lowering to bytecode (and other stuff like weaving) occurs…if it’s also incremental or only happens when you signal the commit (via saving). So, the common misconception that eclipse uses javac in incorrect. This is easy to see by having an error. Javac will bail (not producing a class file), where the eclipse compiler will inject a code sequence to throw an exception if you hit it.

Wow Eclipse is quite complex! Makes me like it even more :slight_smile: