Provider[] provs = Security.getProviders(); String msg = algorithm; for (int i = 0; i < provs.length; i++) {
Provider[] p = Security.getProviders(); NoSuchAlgorithmException lastException = null; for (int i = 0; i < p.length; i++)
  public static final KeyAgreement getInstance(String algorithm)    throws NoSuchAlgorithmException  {    Provider[] provs = Security.getProviders();    String msg = algorithm;    for (int i = 0; i < provs.length; i++)      {        try          {            return getInstance(algorithm, provs[i]);          }        catch (NoSuchAlgorithmException nsae)          {            msg = nsae.getMessage();          }      }    throw new NoSuchAlgorithmException(msg);  }