Firstly, the various diagrams in UML ("Class Diagram", "Package Diagram", "Sequence Diagram", etc.) are more of a conceptual convenience, rather than restriction on what you can visualize, as noted in Annex A:
Annex A
This taxonomy provides a logical organization for the various major kinds of diagrams. However, it does not
preclude mixing different kinds of diagram types, as one might do when one combines structural and behavioral
elements (e.g., showing a state machine nested inside an internal structure). Consequently, the boundaries between the
various kinds of diagram types are not strictly enforced.
This means that you can safely put packages in class diagrams and vice versa, because those terms do not mean much.
The more important question however is, whether there can be a dependency between classes and packages, and according to specs we can:
7.7.3.2
A Usage is a Dependency in which one NamedElement requires another NamedElement (or set of NamedElements) for
its full implementation or operation. The Usage does not specify how the client uses the supplier other than the fact that
the supplier is used by the definition or implementation of the client.
Since both Class
and Package
are subclasses of NamedElement
, you can have a Dependency
between them.