如何将 Java 文件导入 Eclipse
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4657815/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to import Java file into Eclipse
提问by sean
I have downloaded a JAVA FILE and I don't know how to import it in Eclipse.
我已经下载了一个 JAVA 文件,但我不知道如何在 Eclipse 中导入它。
回答by Cristian
If it's a plain Java file (.java), just put it somewhere inside the src
folder of your project. Also, you will have to change its package name, so if it says:
如果它是一个普通的 Java 文件 (.java),只需将它放在src
项目文件夹中的某个位置即可。此外,您将不得不更改其包名称,因此如果它显示:
package com.some.package;
And you copy it to src/com/your/app
, then you have to change the package name to this:
然后将其复制到src/com/your/app
,然后必须将包名称更改为:
package com.your.app;
By the way, there's no "Import Java file" option in Eclipse, don't waste time looking for an automatic way to do it.
顺便说一句,Eclipse 中没有“导入 Java 文件”选项,不要浪费时间寻找自动执行此操作的方法。
回答by Evripidis Yuri Gazetis
The best way is take the file and drop it to the default workspace eclipse folder. Then open the eclipse and refresh the project
最好的方法是将文件放到默认的工作区 eclipse 文件夹中。然后打开eclipse并刷新项目
回答by TheCottonSilk
If you want to create a new project out of it then follow:
如果您想从中创建一个新项目,请执行以下操作:
New -> Java Project -> Create Project from existing source.
新建 -> Java 项目 -> 从现有源创建项目。
Give correct path and proceed further.
给出正确的路径并继续前进。