title: Okay to catch UnsatisfiedLinkError to fall back to a different DLL on a call to System.LoadLibrary?
body: <p>At startup, I want my Java program to load a DLL that should be on the path defined by java.library.path. However, if that DLL is missing, I want my program to fall back to loading a different DLL. System.LoadLibrary throws an UnsatisfiedLinkError if it can't find the DLL file. UnsatisfiedLinkError is a subclass of Error, not of Exception. Lots of commentary suggests that it is bad practice to catch Error. Is this a case where it is okay to do something like this?</p>
  
  <pre><code>try
  {
      System.loadLibrary("myLibrary");
  }
  catch (UnsatisfiedLinkError e)
  {
      try
      {
          System.load(&lt;a fully qualified path to my fall-back library&gt;);
      }
      catch (UnsatisfiedLinkError e)
      {
          &lt;report that even the fall-back library didn't load&gt;;
      }
  }
  </code></pre>