You can't, since there is no such thing as nested packages in java. You must import both packages explicitly.
import LibA.pack1.*;
import LibA.pack2.*;
LibA.pack1
is not related in any way to LibA.pack2
, and both of them have no relation to LibA
package, so if LibA
has additional classes you wish to import, you'll need a 3rd import :
import LibA.*;
Apparent Hierarchies of Packages
At first, packages appear to be hierarchical, but they are not. For example, the Java API includes a java.awt package, a java.awt.color package, a java.awt.font package, and many others that begin with java.awt. However, the java.awt.color package, the java.awt.font package, and other java.awt.xxxx packages are not included in the java.awt package. The prefix java.awt (the Java Abstract Window Toolkit) is used for a number of related packages to make the relationship evident, but not to show inclusion.
Importing java.awt.* imports all of the types in the java.awt package, but it does not import java.awt.color, java.awt.font, or any other java.awt.xxxx packages. If you plan to use the classes and other types in java.awt.color as well as those in java.awt, you must import both packages with all their files:
import java.awt.*;
import java.awt.color.*;