[英]Imported class files are shown under default package in Eclipse, how can i access them?
I am new in Java and Eclipse. 我是Java和Eclipse的新手。
I am trying to import external class files in my code. 我试图在我的代码中导入外部类文件。 I right click on project src->properties->buildpath->configure build path-> libraries->add external class folder by doing this default package appears in referenced libraries, having all the Java class files, but I still can't import my file.
我右键单击项目src-> properties-> buildpath-> configure build path-> libraries-> add external class文件夹,方法是将此默认包显示在引用的库中,包含所有Java类文件,但是我仍然无法导入我的档案。
Next I zip all .class files in a zip folder and add as external jars, by doing this all class files are shown under default package, under referenced libraries, and still I can't import my class files into code. 接下来,我将所有.class文件压缩到zip文件夹中,并添加为外部jar,这样做是将所有类文件显示在默认包下,引用的库下,但仍然无法将我的类文件导入代码中。
How can I rename the default package, so that I can access and import the class files? 如何重命名默认软件包,以便可以访问和导入类文件?
By right clicking the classes, under the default package in the referenced libraries, there comes no option of refactor and move. 通过右键单击这些类,在引用的库中的默认包下,没有重构和移动的选项。
You have to respect the File System Hierarchy in which the class files come from. 您必须遵守类文件来自的文件系统层次结构。
Let's assume that the class files (For example the class Clazz) have the declaration package ch.charno.xy
, they must remain in a folder hierarchy ch/charno/xy/Clazz.class
. 假设类文件(例如
package ch.charno.xy
类)具有声明package ch.charno.xy
,它们必须保留在文件夹层次结构ch/charno/xy/Clazz.class
。 You have to import the folder in which the subfolder ch
resides so that the correct hierarchy is preserved. 您必须导入子文件夹
ch
所在的文件夹,以便保留正确的层次结构。 It's not possible to just import the class files, but you need to import the whole folder hierarchy. 不可能仅导入类文件,但需要导入整个文件夹层次结构。
(I hope I understood your question) (希望我能理解你的问题)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.