Topic: 关于JCE的使用,这个错误怎么回事? |
Print this page |
1.关于JCE的使用,这个错误怎么回事? | Copy to clipboard |
Posted by: feiggle Posted on: 2003-04-14 15:52 看到论坛上一篇文章,照着作了,如下代码: // GenerateKey.java import java.security.SecureRandom; import javax.crypto.KeyGenerator; import javax.crypto.SecretKey; public class GenerateKey { static public void main(String args[]) throws Exception { //String keyFilename = args[0]; String keyFilename="c:\\key"; String algorithm = "DES"; // 生成密匙 SecureRandom sr = new SecureRandom(); KeyGenerator kg = KeyGenerator.getInstance(algorithm); kg.init(sr); SecretKey key = kg.generateKey(); // 把密匙数据保存到文件 Util.writeFile(keyFilename, key.getEncoded()); } } 代码好像没错,运行时,出现如下错误,那位大侠遇到过?请指教! jre为1.4.1_02,用到的jar都加到classpath中了 错误信息: java.lang.NoClassDefFoundError: javax/crypto/KeyGeneratorSpi at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:502) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123) at java.net.URLClassLoader.defineClass(URLClassLoader.java:250) at java.net.URLClassLoader.access$100(URLClassLoader.java:54) at java.net.URLClassLoader$1.run(URLClassLoader.java:193) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:186) at java.lang.ClassLoader.loadClass(ClassLoader.java:299) at java.lang.ClassLoader.loadClass(ClassLoader.java:255) at javax.crypto.SunJCE_b.c(DashoA6275) at javax.crypto.SunJCE_b.a(DashoA6275) at javax.crypto.KeyGenerator.getInstance(DashoA6275) at avicit.encrypted.GenerateKey.main(GenerateKey.java:17) |
2.Re:关于JCE的使用,这个错误怎么回事?(is Sun a bug? ) [Re: feiggle] | Copy to clipboard |
Posted by: menzy Posted on: 2003-04-15 13:13 看情况是没有发现 实现 KeyGenerator的接口类,可能是没有任何类提供相应的服务,也就是说,应当AddServiceProvider(new TheImplementorClass()) |
3.Re:关于JCE的使用,这个错误怎么回事?(is Sun a bug? ) [Re: feiggle] | Copy to clipboard |
Posted by: feiggle Posted on: 2003-04-15 15:03 i try it,thanks |
4.Re:关于JCE的使用,这个错误怎么回事? [Re: feiggle] | Copy to clipboard |
Posted by: iwtg Posted on: 2003-05-29 09:09 可以运行的,我没有用你的写文件,而是直接输出来,正常 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |