Will-i-Am-Davidon
Will-i-Am-Davidon

Reputation: 1762

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

For example, in the following example of log4j.jar: log4j jar folder path to class file Logger.class

to import:

import org.apache.log4j.Logger;

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

Upvotes: 0

Views: 1520

Answers (1)

Thilo
Thilo

Reputation: 262464

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.

Upvotes: 1

Related Questions