Get all packages

static Package[] getPackages()
Get all the packages currently known for the ClassLoader.

public class Main {
  public static void main(String[] args) {
    Package[] ps = Package.getPackages();
    
    for(Package p:ps){
      System.out.println(p);
    }

  }
}

The output:


...
...
...
...
package java.applet, Java Platform API Specification, version 1.6
package java.lang.ref, Java Platform API Specification, version 1.6
package javax.swing.event, Java Platform API Specification, version 1.6
...
...
...
...
Home 
  Java Book 
    Reflection  

Package:
  1. Package Reflection
  2. Get package for a name
  3. Get all packages
  4. Get the annotations
  5. Get implementation title, vendor and version
  6. Get the package name
  7. Get the specification title, vendor and version
  8. Get the string representation of the Package