如何阻止Eclipse 3.4失去对项目中JRE的引用

时间:2023-02-05 11:40:59

Sometimes when using eclipse it loses references to the JRE.

有时使用eclipse时会丢失对JRE的引用。

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

即它找不到像Object或Arraylist这样的类。

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

有些项目报告了问题,而有些项目没有,他们都使用相同的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

我发现,如果你将已安装的JRE切换到另一个,然后再返回到你想要使用的那个,那么它将再次工作

Is there a better way to stop it doing this?

有没有更好的方法来阻止它这样做?

EDIT: Reloading Eclipse doesn't solve the problem

编辑:重装Eclipse不能解决问题

6 个解决方案

#1


2  

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.

我可能有这个决议。 Eclipse几乎每天都在丢失我的许多Java项目中的JRE引用,并且重新启动或启动-clean并没有帮助。我意识到它显然是某种类的类加载器问题,所以我所做的是在编辑器中打开每个项目的“.classpath”文件,并手动将JRE引用classpathentry行移动到文件中的第一个条目,希望它会在任何其他类可能影响它成功加载的能力之前加载JRE。

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.

我认为文件以“。”开头。在默认的eclipse安装中,在资源管理器资源管理器中被过滤器隐藏,因此您可能需要禁用“。* Resources”过滤器才能打开“.classpath”文件。

#2


2  

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.

项目中的JRE引用使用您在Installed JREs首选项页面中提供的名称进行存储。更改名称,您将破坏参考。只需选择在切换JRE时可以重复使用的名称,或者选择工作区默认为项目的JRE。

#3


1  

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

它发生在我身上,但在重新加载Eclipse后,一切都继续运行良好!

#4


0  

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.

就我个人而言,我会把它归咎于日食中的错误。检查并确保在eclipse中安装了JRE安装源zip。我知道你的痛苦。 Eclipse非常棒,但它仍有一些小错误。

#5


0  

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.

我有同样的经历。只有在木卫三。始终是同一个项目。删除项目(但不是当然的源)并重新创建项目会暂时修复它。似乎很高兴一两个星期,然后再次发生。

#6


0  

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.

在启动eclipse时运行-clean标志将从eclipse中删除临时垃圾并使eclipse整体运行得更好。我在这方面取得了不同的成功,实现起来比重新创建项目或重新安装eclipse要容易得多。试一试,看看会发生什么。

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

即使这不适用于3.4,它仍然适用。 http://www.eclipsezone.com/eclipse/forums/t61566.html

#1


2  

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.

我可能有这个决议。 Eclipse几乎每天都在丢失我的许多Java项目中的JRE引用,并且重新启动或启动-clean并没有帮助。我意识到它显然是某种类的类加载器问题,所以我所做的是在编辑器中打开每个项目的“.classpath”文件,并手动将JRE引用classpathentry行移动到文件中的第一个条目,希望它会在任何其他类可能影响它成功加载的能力之前加载JRE。

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.

我认为文件以“。”开头。在默认的eclipse安装中,在资源管理器资源管理器中被过滤器隐藏,因此您可能需要禁用“。* Resources”过滤器才能打开“.classpath”文件。

#2


2  

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.

项目中的JRE引用使用您在Installed JREs首选项页面中提供的名称进行存储。更改名称,您将破坏参考。只需选择在切换JRE时可以重复使用的名称,或者选择工作区默认为项目的JRE。

#3


1  

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

它发生在我身上,但在重新加载Eclipse后,一切都继续运行良好!

#4


0  

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.

就我个人而言,我会把它归咎于日食中的错误。检查并确保在eclipse中安装了JRE安装源zip。我知道你的痛苦。 Eclipse非常棒,但它仍有一些小错误。

#5


0  

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.

我有同样的经历。只有在木卫三。始终是同一个项目。删除项目(但不是当然的源)并重新创建项目会暂时修复它。似乎很高兴一两个星期,然后再次发生。

#6


0  

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.

在启动eclipse时运行-clean标志将从eclipse中删除临时垃圾并使eclipse整体运行得更好。我在这方面取得了不同的成功,实现起来比重新创建项目或重新安装eclipse要容易得多。试一试,看看会发生什么。

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

即使这不适用于3.4,它仍然适用。 http://www.eclipsezone.com/eclipse/forums/t61566.html