sun.security.pkcs11 on javafx

纵然是瞬间 提交于 2019-12-04 04:07:09

问题


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)

回答1:


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




回答2:


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!