Get package for a name

ReturnMethodSummary
static PackagegetPackage(String name)Find a package by name

public class Main {
  public static void main(String[] args) {
    Package p = Package.getPackage("javax.swing");
    System.out.print("Swing Version: ");
    System.out.println(p.getSpecificationVersion());

    p = Package.getPackage("java.awt");
    System.out.print("AWT Version: ");
    System.out.println(p.getSpecificationVersion());

  }
}

The output:


Swing Version: 1.6
AWT Version: 1.6
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.