views:

790

answers:

7

Sometimes when using eclipse it loses references to the JRE.

i.e. It cannot find classes like Object or Arraylist.

Some projects report a problem while others don't and they both use the same JRE.

I have found that if you switch the installed JRE to another and then back again to the one you want to use, it will then work again

Is there a better way to stop it doing this?

EDIT: Reloading Eclipse doesn't solve the problem

+1  A: 

It happened to me, but after a reloading of Eclipse all continued working well!

Enreeco
A: 

Personally, I would chalk this up to bugs in eclipse. Check and make sure the source zip is installed with your JRE installation in eclipse. I know your pain. Eclipse is fantastic, but it still has some minor bugs.

scubabbl
I think you are right, its a bug but its been about a while, was also in 3.3 and 3.2
Craig Angus
A: 

I've had the same experience. Only in Ganymede. Always the same project. Deleting the project (but not the source of course) and re-creating the project fixes it temporarily. Seems to be happy for a week or two and then happens again.

Paul Croarkin
his sounds very similar to my problem
Craig Angus
A: 

Running the -clean flag when starting eclipse will remove temporary junk from the eclipse and make eclipse run better overall. I've had varying success with this, and it's a lot easier to implement than recreating the project or reinstalling eclipse. Give it a shot and see what happens.

Even though this is not for 3.4, it still applies. http://www.eclipsezone.com/eclipse/forums/t61566.html

Spencer K
+1  A: 

The JRE reference in your project is stored using the name you give it in the Installed JREs preference page. Change the name and you break the reference. Just pick names you can keep reusing when switching JREs, or select the workspace default as the JRE for the project.

nitind
Do you mean that if you have two names for teh same JRE and switch whenever it happens?
Craig Angus
+1  A: 

This problem occurred in Europa as well. No solution found yet.

+1  A: 

I may have a resolution for this. Eclipse was losing the JRE references on many of my Java projects almost daily, and restarting or starting with -clean wasn't helping. I realised that it is clearly a classloader issue of some kind, so what I did was to open the ".classpath" file of each project in the editor and manually move the JRE reference classpathentry line to be the first entry in the file, in the hope that it would load the JRE before any other classes which might be affecting it's ability to load successfully.

Since doing this, the problem has not reoccurred.

I think the files starting with a "." are hidden by filter in the package explorer on a default eclipse install, so you may need to disable the ".* Resources" filter to be able to open the ".classpath" file.

Alohci
interesting solution, I will try this the next time it occurs and see if it resolves it
Craig Angus