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

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

问题描述

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

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.

添加:

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

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?

添加了 2 个:

当我尝试创建一个名为game"的项目时,eclipse 告诉我已经存在一个具有该名称的项目.但是我怎样才能打开这个项目?

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?

添加了 3 个:

在我的工作区"中,我创建了一个名为game"的子目录.我将我所有的 .java 文件复制到这个子目录中.然后使用 Eclipse 我创建了一个名为 game 的新项目.结果,Eclipse 在目录game"中创建了.classpath.project 文件.它还创建了 binsrc 子目录.现在我认为这不是正确的方法.源文件应该在src"目录中.对?目前我所有的 .java 文件都在工作区游戏"中.

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 "workspacegame".

添加了 4 个:

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

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?

推荐答案

最简单的方法:

  1. 将所有源文件放在一个以您的项目命名的目录中.即ProjectName"您可以将此目录保留在您的工作区中,也可以位于其他位置.
  2. 在 eclipse 中启动一个新项目并使用相同的项目名称命名它.
  3. 取消选中使用默认位置"框并找到您的项目所在的目录除非您的项目已经在工作区中 - 那么您不得取消选中使用默认位置"框
  4. 点击下一步".
  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 应该足够聪明,可以弄清楚发生了什么.单击下一步后,它将显示在该目录中找到的所有文件.它只会自动将这些文件添加到您的项目中.瞧!

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天全站免登陆