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 :-
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.
来源:https://stackoverflow.com/questions/15787245/sun-security-pkcs11-on-javafx