how to determine package name of a class in a jar file

吃可爱长大的小学妹 提交于 2019-12-24 22:14:50

问题


For example, in the following example of log4j.jar:

to import:

import org.apache.log4j.Logger;

Is package name "org.apache.log4j" determined by the path \org\apache\log4j\Logger.class?


回答1:


Yes, the package name needs to match the path in the jar file (or directory). Otherwise the class cannot be found.

However, you cannot just move the class file around to change the package. It is also encoded into the class bytecode itself. If you want to change it, you need to recompile the class.



来源:https://stackoverflow.com/questions/29812204/how-to-determine-package-name-of-a-class-in-a-jar-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!