Package-level annotations apply to all classes in a package and live in under that package's directory.

Its specification is at JLS 7.4.1.

You can see an example of this in JAXB, which takes advantage of package-level annotations in declaring the default namespace to use in a package. Actually, it seems to be mandatory to declare a default namespace in if namespaces used as "markers", but are not backed by an XML schema. (Take that last part with a grain of salt.)

@javax.xml.bind.annotation.XmlSchema(namespace = "", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)

You can then override the default namespace on sub elements within that package by using the proper annotation:


public class Something { 
    public static class Subthing { }

Both Something and Something.Subthing will have an empty namespace, despite the package-level namespace being