Thanks for the help Richard!

This solution works.


Greetings,

Bart


Richard S. Hall wrote:
Bart Elen wrote:
Hello,


When a package is imported with 'resolution:=optional', we have to check if the package is available or not before we use it. But how do we do this?

Someone has experience with this problem?

Just try to load a class from that package and catch any exceptions...if you load the class successfully, then the package is available, if not then don't try to load any more, e.g.:

   boolean fooAvailable = false;
   try {
       this.getClass().getClassLoader().loadClass("org.foo.MyClass");
       fooAvailable = true;
   } catch (Exception ex) {
       // foo is not available.
   }

Something like that.

-> richard




Thanks,

Bart

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to