如何从Eclipse中的现有源创建一个项目,然后找到它? [英] How to create a project from existing source in Eclipse and then find it?

查看:148
本文介绍了如何从Eclipse中的现有源创建一个项目,然后找到它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了几个.java文件。它们都位于一个目录中。我使用文本编辑器来编写这些文件。现在我想切换到Eclipse。我该怎么做?我尝试了很多方法。



ADDED:



我认为常见的方法是在eclipse文件夹中有源文件夹叫做工作区。那么,如何在这些目录中获取我的文件。我应该使用eclipse从现有的源创建一个新的项目,Eclipse会把所有的文件放到工作区?或者我应该手动将我的所有文件复制到工作区?我应该把我的类文件放在哪里?我应该创建一个子目录?用哪个名字?



ADDED 2:



当我尝试创建一个项目名称为游戏,日食写道,一个名称已经存在的项目。但是如何打开这个项目?



添加3:



在我的workspace我创建了一个名为game的子目录。我将所有.java文件复制到这个子目录中。然后用Eclipse我创建了一个名称游戏的新项目。因此,Eclipse在目录game中创建了 .classpath .project 文件。它还创建了 bin src 子目录。现在我认为这不是正确的方法。源文件应该在src目录中。对?目前我所有的.java文件都在workspace\game中。



添加4:



我做了其他方式。用Eclipse我创建了一个名为game的新项目。结果,Eclipse在文件夹工作区中创建了一个名为游戏的文件夹。在游戏的文件夹我找到src文件夹。我将所有.java文件复制到此文件夹中。但现在在包资源管理器中,我无法打开src文件夹。那么,如何从Eclipse访问我的源文件?为什么Eclipse不想打开src文件夹?

解决方案

最简单的方法:


  1. 将所有源文件放入一个以项目命名的目录中。即ProjectName您可以将此目录保存在工作空间中,也可以在其他位置。

  2. 在eclipse中启动一个新项目,并使用相同的项目名称命名。

  3. 取消选中使用默认位置框,找到您的项目是的目录,除非您的项目已经在工作区中,否则您不能取消选中使用默认位置框

  4. 点击下一步。

Eclipse应该足够聪明,弄清楚发生了什么。点击下一步后,它将显示该目录中找到的所有文件。它会自动将这些文件添加到您的项目中。 Voilà!


I have created several .java files. All of them are located in one directory. I used a text editor to write these files. Now I want to switch to Eclipse. How can I do it? I have tried many ways. None of them works.

ADDED:

I think the common way is to have source in the eclipse folder called "workspace". So, how do I get my files in these directory. Should I use eclipse to create a new project from existing source and Eclipse will put all file to the workspace? Or I should manually copy all my files to the workspace? Where should I put my class files than? Should I create a subdirectory? With which name?

ADDED 2:

When I try to create a project with name "game", the eclipse writes me that a project with such name already exist. But how can I open this project?

ADDED 3:

In my "workspace" I have created a subdirectory called "game". I copied all my .java file into this subdirectory. Then with Eclipse I created a new project with the name game. As a result, Eclipse created .classpath and .project files in the directory "game". It also created bin and src subdirectories. And now I think it is not the correct way to go. The source files are supposed to be in the "src" directory. Right? And at the moment all my .java files are in the "workspace\game".

ADDED 4:

I did it other way around. With Eclipse I have created a new project with the name "game". As the result, Eclipse created a folder called "game" into folder "workspace". In "game" the folder I found "src" folder. I copied all my .java files into this folder. But now in the "Package Explorer" I cannot open "src" folder. So, how can I access my source files from Eclipse? Why Eclipse does not want to open the "src" folder?

解决方案

Easiest Method:

  1. Put all source files into one directory named after your project. i.e. "ProjectName" You can keep this directory in your workspace or it can be somewhere else.
  2. Start a new project in eclipse and name it using that same project name.
  3. Uncheck the "use default location" box and find the directory where your project is unless your project is already in the workspace - then you must not uncheck the "use default location" box
  4. Click 'next'.

Eclipse should be smart enough to figure out what's going on. After clicking next, it will show you all of the files it found in that directory. It will just automatically add those files to your project. Voilà!

这篇关于如何从Eclipse中的现有源创建一个项目,然后找到它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆