Searching...
Saturday, 30 November 2013

How to get Package information for a given class in java

00:26

Example

package com.pretech;
public class PackageInfoExample {
	public static void main(String[] args) {
		Class<String> clazz = String.class;
		Package pack = clazz.getPackage();
		System.out.println(pack);
		System.out.println(pack.getImplementationTitle());
		System.out.println(pack.getName());
		System.out.println(pack.getSpecificationTitle());
	}
}

Output



package java.lang, Java Platform API Specification, version 1.7
Java Runtime Environment
java.lang
Java Platform API Specification


0 comments: