You have to ask a ClassLoader for them...
class MyClassLoader extends ClassLoader {
public MyClassLoader() {
}
public Package[] getPackages() {
return super.getPackages();
}
}
for (Package pkg : new MyClassLoader().getPackages()) {
System.out.println(pkg);
}
Sorry for following late on this Tim. My issues are as follows,
1. With -verbose option, I need to display the name of jar file which
is currently checked.
But Package instance does not have jar file info from which it is
read from.
2. I can obtain package instance manually using manifest file's
attribute "Name"
But most of the jars seem to be missing it and still have
"Specification-Title" and
"Specification-version" attributes present. (Which are good enough
to do the comparison)
Here are my suggestions,
1. I use manual jar manifest parsing for extcheck instead of Package.
2. Let me copy the isCompatible() code for right now.
3. We can move isCompatible as static method somewhere at kernel classes
level.
4. Reuse this method wherever needed then.
I checked the RI code and it also seems to be parsing jar files manually.
---------
Kalpak