title: BouncyCastle installation problems
body: <p>I'm trying to add BouncyCastle as a security provider on Windows XP Pro so I can use it to add some certs to an Android application per the instructions <a href="http://blog.crazybob.org/2010/02/android-trusting-ssl-certificates.html" rel="noreferrer">here</a>. Unfortunately I can't get it to add the provider.</p>
  
  <p>I've:</p>
  
  <ol>
  <li>Downloaded the provider to <code>C:\Program Files\Java\jre6\lib\ext\</code>.</li>
  <li>Added <code>C:\Program Files\Java\jre6\lib\ext\bcprov-jdk16-146.jar</code> to <code>%CLASSPATH%</code>.</li>
  <li>Added <code>security.provider.7=org.bouncycastle.jce.provider.BouncyCastleProvider</code> to java.security (7 being the next int in the order).</li>
  </ol>
  
  <p>When I run:</p>
  
  <pre><code>keytool -import -v -trustcacerts -alias 0 -file mycert.crt -keystore mystore.bks -storetype BKS -providerName org.bouncycastle.jce.provider.BouncyCastleProvider -storepass mypassword 
  </code></pre>
  
  <p>I get the following error message:</p>
  
  <pre><code>keytool error: java.lang.ClassNotFoundException: org.bouncycastle.jce.provider.BouncyCastleProvider
  </code></pre>
  
  <p>I've also tried adding it dynamically:</p>
  
  <pre><code>import java.security.Provider;
  import java.security.Security;
  import java.util.Enumeration;
  
  import org.bouncycastle.jce.provider.BouncyCastleProvider;
  
  public class BouncyCastleMain {
  
      public static void main(String[] args) throws Exception {
          Security.addProvider(new BouncyCastleProvider()); // add it
          try { // list them out
              Provider p[] = Security.getProviders();
              for (int i = 0; i &lt; p.length; i++) {
                  System.out.println(p[i]);
                  for (Enumeration&lt;?&gt; e = p[i].keys(); e.hasMoreElements();)
                      System.out.println("\t" + e.nextElement());
              }
          } catch (Exception e) {
              System.out.println(e);
          }
      }
  }
  </code></pre>
  
  <p>At first I got an access error when compiling the java class, but changed it to a warning per the suggestion <a href="http://lkamal.blogspot.com/2008/09/eclipse-access-restriction-on-library.html" rel="noreferrer">here</a>. Now when I run the code it shows BouncyCastle in the list of providers but it doesn't stick around after the program is done.</p>
  
  <p>I'm sure it must be doable, but I'm stymied over how to get this guy installed long enough to run keytool using it. Is it possible to run keytool via a java API, or could there be some step I've missed that will make the provider stick around?</p>
  
  <p>Thanks!</p>