简体   繁体   English

Eclipse在何处为不在工作区中的项目保存文件?

[英]Where does Eclipse save files for projects not in workspace?

Where does Eclipse save .java files for projects that are not in my workspace? Eclipse将不在我的工作空间中的项目的.java文件保存在哪里? Basically, I downloaded a project from a friend, and imported that project to Eclipse. 基本上,我从朋友那里下载了一个项目,然后将该项目导入了Eclipse。 I edited and created new packages and files in the project. 我在项目中编辑并创建了新的程序包和文件。 Then, I exported the project and uploaded it to a file sharing website. 然后,我导出了该项目并将其上传到文件共享网站。 A couple days later, (my computer had restarted since then), I reopened Eclipse. 几天后(从那以后我的计算机已经重新启动),我重新打开了Eclipse。 My files weren't there, so I tried looking for them on my computer and couldn't find anything. 我的文件不存在,所以我尝试在计算机上寻找它们,但找不到任何东西。 I went back to the website I had uploaded the files too, and all the files were completely blank. 我回到网站,我也上传了文件,所有文件完全空白。

I was thinking that the issue may have been the fact that Eclipse saves files into the project folder within the workspace. 我当时在想问题可能是Eclipse将文件保存到工作区中的项目文件夹中的事实。 However, since the project came from my friend, that project didn't exist in MY workspace. 但是,由于该项目来自我的朋友,因此该项目在我的工作空间中不存在。 If this is the case, then where was Eclipse storing those files whenever I saved them? 如果是这种情况,那么每当我保存文件时,Eclipse会将它们存储在哪里? Was it some sort of local memory within the Eclipse program that just gets erased when I restart my computer? 重新启动计算机后,Eclipse程序中是否只是某种本地内存? Any information would be greatly appreciated. 任何信息将不胜感激。

Eclipse uses the normal file system. Eclipse使用普通的文件系统。 But if you used the import wizard Existing Projects into Workspcace without the option Copy projects into workspace or the Projects from Folder or Archive import wizard, then the folder to import was referenced and not copied. 但是,如果您使用导入向导将现有项目导入到Workspcace中,而没有选择将项目复制到工作区中从文件夹导入项目或从存档导入向导,则将引用并没有复制要导入的文件夹。 Maybe you have then deleted the supposedly copied folder. 也许您然后删除了假定复制的文件夹。 In this case, Eclipse would display a closed project folder. 在这种情况下,Eclipse将显示一个关闭的项目文件夹。 You can right-click the closed project folder and choose Properties : in Resource the now deleted directory is displayed as Location . 您可以右键单击关闭的项目文件夹,然后选择“ 属性” :在“ 资源”中 ,现在删除的目录显示为“ 位置”

To (at least partially) restore the files you edited: 要(至少部分地)还原您编辑的文件:

  1. Recreated the deleted folder 重新创建已删除的文件夹
  2. In the recreated folder create the file .project with following content (replace Foo with the project/folder name): 在重新创建的文件夹中,创建具有以下内容的文件.project (用项目/文件夹名称替换Foo ):

     <?xml version="1.0" encoding="UTF-8"?> <projectDescription> <name>Foo</name> <comment></comment> <projects> </projects> <buildSpec> </buildSpec> <natures> </natures> </projectDescription> 

  3. In Eclipse open the project: right-click and choose Open Project 在Eclipse中打开项目:右键单击并选择Open Project。

  4. Right-click on the project folder and choose Restore from Local History... 右键单击项目文件夹,然后选择“从本地历史记录中还原...”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM