Вопрос

I try to develop a javafx aplication that access a smartcard.

I have a simple proof of concept, like this:

package javafxapplication7;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import sun.security.pkcs11.SunPKCS11;


public class SampleController implements Initializable {

   @FXML
   private Label label;

   @FXML
   private void handleButtonAction(ActionEvent event) {
      SunPKCS11 a = new SunPKCS11();
   }

   @Override
   public void initialize(URL url, ResourceBundle rb) {
       // TODO
   }    
}

and the exepcion is:

Caused by: java.lang.NoClassDefFoundError: sun/security/pkcs11/SunPKCS11
at javafxapplication7.SampleController.handleButtonAction(SampleController.java:26)
Это было полезно?

Решение

Just install a 32bit JDK along side (or instead) of your 64 bit JDK, and make sure you compile and sign the JAR/COD file with the 32 bit version.

Actually it is a bug in the 64 bit version.. http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=f1279f413fd19e3a247022d6dcca9?bug_id=7105065

I found it in the following discussions :-

http://www.java.net/node/703858

http://tai-dev.blog.co.uk/2009/11/11/are-you-seeing-the-java-lang-noclassdeffounderror-sun-security-pkcs11-sunpkcs11-error-when-signing-your-rim-blackberry-j2me-apps-7352729/

http://community.igniterealtime.org/thread/30821

Другие советы

Regardless of why you get this specific issue, don't use sun.* classes. They are not designed for public use.

You probably want to be using the SunPKCS11 JCE provider to work with your smart card. Take a look at this guide to help get you started: http://docs.oracle.com/javase/1.5.0/docs/guide/security/p11guide.html.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top