简体   繁体   English

如何将* .java文本文件导入Eclipse项目?

[英]How do I import *.java text files into an Eclipse project?

I'm finally biting the bullet and starting use Eclipse (Europa for now) instead of command-line java and Notepad. 我终于咬紧牙关并开始使用Eclipse(现在是Europa)而不是命令行java和Notepad。 However, I've not really organized my projects apart from naming conventions (eg, ProjAClassname1, ProjAClassname2, ProjAClassname3, etc) and they're all in my JRE java/bin directory. 但是,我没有真正组织我的项目,除了命名约定(例如,ProjAClassname1,ProjAClassname2,ProjAClassname3等),它们都在我的JRE java / bin目录中。 I have a directory full of *.java files that I want to start organizing into a brand new install of Eclipse. 我有一个充满* .java文件的目录,我想开始组织到Eclipse的全新安装中。

I've followed the instructions in the Eclipse help files, googled for a while and I've found some excellent Stack answers on importing JAR files , importing existing Eclipse projects . 我已经按照Eclipse帮助文件中的说明进行了一段时间的谷歌搜索,我在导入JAR文件导入现有 Eclipse项目时找到了一些优秀的Stack答案。 However, none of these work. 但是,这些都不起作用。 None of the resulting dialogs show a list of files to import/add; 结果对话框都不显示要导入/添加的文件列表; I think they assume that all my classes are contained in *.jar files instead of *.java files. 我认为他们假设我的所有类都包含在* .jar文件中而不是* .java文件中。

I created java\\bin\\ProjA\\src and copied all my source code *.java; 我创建了java \\ bin \\ ProjA \\ src并复制了我的所有源代码* .java; same results. 相同的结果。 The closest I got was creating a new project, then dragging and dropping the *.jave files from Explorer to Eclipse. 我得到的最接近的是创建一个新项目,然后将* .jave文件从Explorer拖放到Eclipse。 The classes all showed up as part of the project, but I had the little red x indicating "out of sync with file system", and even though I found this , none of the solutions offered in that answer worked for me. 这些类都显示为项目的一部分,但是我有一个小的红色x表示“与文件系统不同步”,即使我发现了这个 ,但该答案中提供的解决方案都不适用于我。

Before I start creating new classes and cutting/pasting from Notepad, I wanted to know if there were any other ideas floating out there? 在我开始从记事本创建新类和剪切/粘贴之前,我想知道是否有任何其他想法浮出水面?

You can add your java files by simply dragging them to eclipse, then try doing this 你可以通过简单地将它们拖到eclipse来添加你的java文件,然后尝试这样做

Go to "Project" -> Clean 转到“项目” - >清洁

在此输入图像描述

Then select all projects and click on Ok 然后选择所有项目并单击“确定”

First of all, I would recommend using a newer version of Eclipse. 首先,我建议使用更新版本的Eclipse。 The current version is Kepler (4.3, whereas Europa is 3.3) which means you are about seven releases behind. 目前的版本是开普勒(4.3,而欧罗巴是3.3),这意味着你落后了七个版本。

More to the point, if you have a folder with all your Java files in them, you could use File -> Import and pull in all the files from a directory into the workspace. 更重要的是,如果你有一个包含所有Java文件的文件夹,你可以使用File - > Import并将目录中的所有文件拉入工作区。

To import your project to Eclipse that was coded in other editors such as Textpad and etc., simply open eclipse and make a new project, expand your project, and then go to your folder, take your .java file and other packages and drag it on the source folder in eclipse. 要将项目导入到在其他编辑器(如Textpad等)中编码的Eclipse,只需打开eclipse并创建一个新项目,展开项目,然后转到您的文件夹,获取.java文件和其他包并拖动它在eclipse中的源文件夹上。 You will be prompted and choose "copy to new folders", which is the first option. 系统将提示您并选择“复制到新文件夹”,这是第一个选项。 And enjoy compiling and debugging in Eclipse. 并享受Eclipse中的编译和调试。

  1. Copy and paste Example.java to package Eclipse(called custommath). 将Example.java复制并粘贴到包Eclipse(称为custommath)。
  2. Copy and paste input file to package Eclipse. 将输入文件复制并粘贴到Eclipse包中。
  3. You modified Example.java with package custommath,in first line instead of the input file. 您在第一行而不是输入文件中使用包custommath修改了Example.java。

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

相关问题 如何在Eclipse中的项目中包含.class文件? (JAVA) - How do I include .class files in my project in Eclipse? (Java) 如何将该项目导入Eclipse? - How do I import this project into Eclipse? 如何将缺少.project .settings .classpath文件的java项目导入到eclipse中 - How to import a java project missing .project .settings .classpath files into eclipse 如何将没有.classpath 或.project 文件的android 项目导入Eclipse? - How do you import an android project with no .classpath or .project files into Eclipse? 如何将Netbeans中的非Maven Java项目正确导入Eclipse中的Maven项目? - How do I import a non-Maven Java project in Netbeans to a Maven project in Eclipse properly? 如何组织我的Java Eclipse项目,以便用户只需要进行一次导入? - How do I organize my Java Eclipse project so that the user then only needs to do one import? 如何告诉Eclipse从当前Java Web Project外部导入文件? - How can I tell Eclipse to import files from outside the current Java Web Project? 如何将Java项目导入Eclipse? - How to import a Java project to Eclipse? 如何导入Java项目(Eclipse) - How to import java project (Eclipse) How do I build a Java Github Project in Eclipse with no maven & gradle files and no.jar files in the repo - How do I build a Java Github Project in Eclipse with no maven & gradle files and no .jar files in the repo
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM