如何将.java文件包装到Eclipse项目中 [英] How to take package .java files into a Eclipse Project

查看:181
本文介绍了如何将.java文件包装到Eclipse项目中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个java包的副本,以示例的方式实现。该包是一个名为com.java.project(文件夹,包含多种.java文件)的结构,还有一些示例文件(example1.java,example2.java)

I've got a copy of a java package, with example implementation. The package is in a structure called com.java.project (folders, containing myriads of .java files) and there's also a few example files (example1.java, example2.java)

示例文件中有import com.java.project调用,这一切都很好。但是,我似乎无法找出Eclipse如何找到软件包内容(目前为了对项目对象的任何调用返回Type not found。

The example files have 'import com.java.project' calls in them, that's all well and good. However, I can't seem to work out how to get Eclipse finding the package contents (currently returns "Type not found" for any calls to the project objects.

I我试图将com结构放在与我的example1.java相同的级别,但是这不行,我已经看到,我需要将包编译成.jar,以使其在Eclipse中工作,但这不

I've tried placing the com structure in the same level as my example1.java, but that doesn't work. I have read that I need to compile the package into a .jar to get it to work w/Eclipse, but that doesn't seem to want to behave, none of the files compile.

推荐答案

在Eclipse中,您可以右键单击项目资源管理器选择新建 - > Java项目

In Eclipse you can right click on the Project Explorer and select "New -> Java Project"

然后,您可以通过右键单击项目导入您的java文件,从文件系统中选择导入,如果类文件显示错误,打开类文件,类名应该有红色的花括号,点击错误刻度标记,Eclipse将提供一个选项,将文件移动到正确的包,从而为您创建文件夹结构。

Then you can import your java files by right clicking your project, selecting import from file system. If the class file shows an error, open the class file, the class name should have red curly braces, click on the error tick mark and Eclipse will give you an option to move the file to the correct package which in turn creates the folder structure for you.

这篇关于如何将.java文件包装到Eclipse项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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