You can seal a package in a JAR file.
Sealing a package in a JAR file means that all classes declared in that package must be archived in the same JAR file.
If you change anything in the package, you just recreate a JAR file.
To seal a package in a JAR file, you need to include two attributes: Name and Sealed.
The value for the Name attribute is the name of the package and the Sealed attribute has value as true.
The following entries in a manifest file will seal a package named com.book2s.archives.
The package name must end with a forward slash /
Name: com/book2s/archives/ Sealed: true
By default, all packages in a JAR file are not sealed.
If you want to seal the JAR file itself, you can include a Sealed attributed, as shown:
Sealed: true
Sealing the JAR file will seal all packages in that JAR file.
You can override it by not sealing a package individually.
The following entries in a manifest file will seal all packages in the JAR file, except the book/testjar/ package:
Sealed: true Name: book/testjar/ Sealed: false