简体   繁体   English

关于Java默认软件包(使用Eclipse)

[英]About java default package(using Eclipse)

Now, I'm using some methods by using a jar. 现在,我通过罐子使用一些方法。 But these classes I use have no package names. 但是我使用的这些类没有包名称。

I can use reflection to solve the problem of using these methods.But now I want to override some of the interface and classes. 我可以使用反射来解决使用这些方法的问题。但是现在我想重写一些接口和类。

However,others can extends these classes directly without any compilation error on their computers using Elcipse, while I extends directly, I have this compilation error: 但是,其他人可以使用Elcipse在其计算机上直接扩展这些类而没有任何编译错误,而我直接扩展时,却遇到此编译错误:

(classname) cannot be resolved to a type. (类名)无法解析为类型。

Is there any chance configuration on my Elcipse is different from others? Elcipse上的配置是否与其他配置不同?

I'm so confused now... 我现在很困惑

Just don't do that. 只是不要那样做。

Using the default empty package has no place in "real world" code bases. 使用默认的空包在“现实世界”代码库中没有位置。

Instead of wasting your time on working around those default package classes you refactor them, by putting them into real packages; 与其浪费时间来处理这些默认的包类,还不如通过将它们放入真实的包中来重构它们。 making good use of those access controlling keywords public/private/... 充分利用那些访问控制关键字public / private / ...

Reflection for example should only be used in very special situations. 例如,反射仅应在非常特殊的情况下使用。 For sure not to fix missing package names. 确保不修复缺少的程序包名称。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM