Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
例如,在以下 log4j.jar 示例中:
导入:
import org.apache.log4j.Logger;
包名“org.apache.log4j”是由路径\org\apache\log4j\Logger.class 决定的吗?
是的,包名需要与jar文件(或目录)中的路径相匹配。否则找不到类。
但是,您不能只是移动类文件来更改包。它也被编码到类字节码本身。如果要更改它,则需要重新编译该类。