title: Using j2pkcs11.dll with java 8 (64-bit) on windows 7 (64-bit)
body: <p>I trying to use the j2pkcs11.dll (packaged with jdk1.8.0 - 64bit) to access certificates stored on a smartcard but not unable to make it work. </p>
  
  <p>--- sample code to add the SunPKCS11 provider dynamically ---</p>
  
  <pre><code>    String pkcs11ConfigSettings = "name = " + "TestSmartCard" + "\n" + "library = " + "C:/jdk1.8.0_11/jre/bin/j2pkcs11.dll";
      byte[] pkcs11ConfigBytes = pkcs11ConfigSettings.getBytes();
      ByteArrayInputStream confStream = new ByteArrayInputStream(pkcs11ConfigBytes);            
      Provider p = new sun.security.pkcs11.SunPKCS11(confStream);
  </code></pre>
  
  <p>---- the exception I get ---</p>
  
  <pre><code>java.security.ProviderException: Initialization failed
      at sun.security.pkcs11.SunPKCS11.&lt;init&gt;(SunPKCS11.java:376)
      at sun.security.pkcs11.SunPKCS11.&lt;init&gt;(SunPKCS11.java:103)
      at scpoc.SmartCard.main(SmartCard.java:28)
  
  Caused by: java.io.IOException: The specified procedure could not be found.
      at sun.security.pkcs11.wrapper.PKCS11.connect(Native Method)
      at sun.security.pkcs11.wrapper.PKCS11.&lt;init&gt;(PKCS11.java:138)
      at sun.security.pkcs11.wrapper.PKCS11.getInstance(PKCS11.java:151)
      at sun.security.pkcs11.SunPKCS11.&lt;init&gt;(SunPKCS11.java:313)
  </code></pre>
  
  <hr>
  
  <p>JEP 131 claims to have PKCS11 support in Java 8 (<a href="http://openjdk.java.net/jeps/131" rel="nofollow">http://openjdk.java.net/jeps/131</a>) but I have not been able to get it to work on windows 7 using the java8 64-bit. Note: I also tried the java 8 32-bit on windows 7 - but no luck either.</p>
  
  <p>Has anyone had any success using the SunPKCS11 provider with java 8 (Windows 7)?</p>