>> Is there anyway to check if a package exists at runtime? Class is
>> simple -
[quoted text clipped - 7 lines]
> Package.getPackages() gets all packages known to the callers
> ClassLoader. At least this is what the documentation says...
public static boolean packageExists(String name) {
return Package.getPackage(name)!=null;
}
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Package.html#getPackage(java.l
ang.String)
robert
Chris Smith - 27 Jan 2006 15:36 GMT
> public static boolean packageExists(String name) {
> return Package.getPackage(name)!=null;
> }
Note that this will return true ONLY when a class from the package has
already been loaded. It does not somehow check if anything from the
package might be available in the future. That is the JVM's definition
of whether the package exists (it doesn't exist until it's first used),
but it's probably not the definition the OP wanted.

Signature
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation