getPackage() returns null for a class in the unnamed package
public class Main { public static void main(String[] argv) throws Exception { Class cls = MyClass.class; Package pkg = cls.getPackage(); // null } } class MyClass{}