简体   繁体   English

导入的类文件显示在Eclipse中的默认软件包下,我如何访问它们?

[英]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.

相关问题 Eclipse-我想从相同的程序包访问一个类,但是在不同的项目下,该怎么办? - Eclipse - I want to access a class from the same package but under a different project, how? 如何在eclipse中看到导入类的代码? - How can I see the code of a imported class in eclipse? 如何使Eclipse将默认包添加到现有项目? - How can I get Eclipse to add a Default Package to an Existing Project? 我如何找到在Java类中导入的文件? - how can i find the files imported in a java class? 我如何在包外访问默认类的公共方法 - how do i access a public method of a default class outside the package 如何在eclipse中添加可以使用import语句导入的包? - how to add a package to eclipse which can be imported using import statement? 在eclipse中创建一个新的Java包(默认包除外),但是不能在此新文件夹中的文件中使用外部库中的类 - Create a new java package in eclipse (apart from default package), but can not use the class from external library in the files in this new folder 如何从Eclipse中的项目的导入JAR中排除软件包? - How do I exclude a package from an imported JAR for a project in Eclipse? 无法从我作为库导入的项目中访问 class 文件 - Can't access class files from project which I imported as a library 如何在我的构建中将导入的jar文件添加到eclipse中的web-inf / lib? - How can I add imported jar files to web-inf/lib in eclipse for my build?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM