您的位置:首页 > 编程语言 > Java开发

从CVS中下载的源码导入到eclipse时会发现快捷键都不能用了

2012-05-24 14:52 826 查看
最近进了一家公司,主要是做Pos机的,从CVS上下载源码import入eclipse时:

发现按F3快捷键的时候,会弹出一个信息:problems opening editor. Reason : the project tms2 does not exist !

当按F4快捷键的时候,会弹出这样的信息:the resource is not on the build path of a java project.

同时ctrl + shift + t 和别的快捷键都不能使用,我们甚至连build path选项也找不到。

这是因为我们从CVS上下载源码导入到我们本地的eclipse中时,项目的路径其实是虚拟的,因此解决办法是配置:.project 文件

下面是我针对自己项目做的配置!(注:该项目用的是java三大框架)

<?xml version="1.0" encoding="UTF-8"?>

<projectDescription>

<name>tms2</name>

<comment></comment>

<projects>

</projects>

<buildSpec>

<buildCommand>

<name>com.genuitec.eclipse.j2eedt.core.WebClasspathBuilder</name>

<arguments>

</arguments>

</buildCommand>

<buildCommand>

<name>org.eclipse.jdt.core.javabuilder</name>

<arguments>

</arguments>

</buildCommand>

<buildCommand>

<name>com.genuitec.eclipse.j2eedt.core.J2EEProjectValidator</name>

<arguments>

</arguments>

</buildCommand>

<buildCommand>

<name>com.genuitec.eclipse.j2eedt.core.DeploymentDescriptorValidator</name>

<arguments>

</arguments>

</buildCommand>

<buildCommand>

<name>com.ibm.etools.validation.validationbuilder</name>

<arguments>

</arguments>

</buildCommand>

<buildCommand>

<name>com.ibm.sse.model.structuredbuilder</name>

<arguments>

</arguments>

</buildCommand>

<buildCommand>

<name>com.genuitec.eclipse.hibernate.HibernateBuilder</name>

<arguments>

</arguments>

</buildCommand>

<buildCommand>

<name>org.springframework.ide.eclipse.core.springbuilder</name>

<arguments>

</arguments>

</buildCommand>

<buildCommand>

<name>org.springframework.ide.eclipse.beans.core.beansvalidator</name>

<arguments>

</arguments>

</buildCommand>

<buildCommand>

<name>com.genuitec.eclipse.ast.deploy.core.DeploymentBuilder</name>

<arguments>

</arguments>

</buildCommand>

</buildSpec>

<natures>

<nature>com.genuitec.eclipse.ast.deploy.core.deploymentnature</nature>

<nature>org.springframework.ide.eclipse.beans.core.beansnature</nature>

<nature>org.springframework.ide.eclipse.core.springnature</nature>

<nature>com.genuitec.eclipse.hibernate.hibernatenature</nature>

<nature>com.genuitec.eclipse.j2eedt.core.webnature</nature>

<nature>org.eclipse.jdt.core.javanature</nature>

<nature>com.genuitec.eclipse.cross.easystruts.eclipse.easystrutsnature</nature>

</natures>

</projectDescription>

当我们配置完成后,改项目可以被成功编译了,但是可能依然会报一个错误:The
type java.lang.Object
cannot be
resolved. It
is indirectly
referenced from required .class files


当你在Eclipse引用不同版本JDK工程时会发生该问题。由于你开发环境中应用了多个版本的JDK 或JRE导致的。Eclipse会按照最初的开发环境默认选择对应的Jre。如Eclipse上有jdk1.4开发的环境工程,当你在引入高版本jdk1.6开发的工程时,以上问题就出现了。

针对这种情况的解决办法是:

进入window\preferences\java\Installed JREs

按Add --> Browse...--->选择jre安装路劲(我的jre路径是D:\Program Files\Java\jre1.6.0_02)--->OK

找到你的工程右键点击Properties选项 出现对话框后 选择右边的Libraries选项卡 ---> 单击Add 了Library...--->


选择Jre System Library... ---> Next--->选择Alternate Jre 下的对应版本jre --> Finish ---> Ok

以上问题就可解决。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: