升级到 Java 7 后编译错误:包 sun.security.pkcs11 不存在
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13710647/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
compile error after upgrading to Java 7: package sun.security.pkcs11 does not exist
提问by wlaem
I just upgraded from Java 6 to Java 7 SDK and am now getting the following error in my ant build:
我刚刚从 Java 6 升级到 Java 7 SDK,现在在我的 ant 构建中出现以下错误:
error: package sun.security.pkcs11 does not exist
Provider p = new sun.security.pkcs11.SunPKCS11(is);
错误:包 sun.security.pkcs11 不存在
Provider p = new sun.security.pkcs11.SunPKCS11(is);
I'm running Windows 7 64-bit. I can compile fine if I switch back to Java 6, but that is not an option any longer. I haven't had much luck finding a solution online. Anybody knows how to resolve this issue?
我正在运行 Windows 7 64 位。如果我切换回 Java 6,我可以很好地编译,但这不再是一个选项。我在网上找到解决方案的运气并不好。有谁知道如何解决这个问题?
回答by Tom G
You will have to convert your application to use APIs which are not restricted. The compiler will warn you quite strictly when you have done such a thing -- this is the consequence of proceeding in the face of those warnings.
您必须将您的应用程序转换为使用不受限制的 API。当你做了这样的事情时,编译器会非常严格地警告你——这是面对这些警告继续进行的结果。
See Why Developers Should Not Write Programs That Call 'sun' Packages
回答by Yassering
I have faced the same problem and i solve it by installing the 32-bit JDK insteade of 64-bit and sure it will work .
我遇到了同样的问题,我通过安装 32 位 JDK 而不是 64 位来解决它,并确保它可以工作。
回答by LucianMLI
The API has not been released by oracle oracle bugand the answers by tom and yassering are both corect.
这个API没有被oracle oracle bug发布,tom和yassering的回答都是正确的。
回答by Atul Soman
Since sunPKCS11 support is not there in Windows 64 bit, i am assuming that you are using windows 64 bit just for build environment and your runtime might be a linux or other supported environments.
由于 Windows 64 位不支持 sunPKCS11,我假设您使用 Windows 64 位仅用于构建环境,并且您的运行时可能是 linux 或其他受支持的环境。
If the above is true, then inorder to make the build work, copy the sunpkcs11.jar from a 32 bit jdk and copy to a 64 bit jdk under jre\lib\ext. This worked for me.
如果上述情况属实,那么为了使构建工作,请将 sunpkcs11.jar 从 32 位 jdk 复制到 jre\lib\ext 下的 64 位 jdk。这对我有用。
Or, alternatively wait for jdk8 where its fixed.
或者,或者等待修复的 jdk8。
回答by jmc
I'm having the same error.
我有同样的错误。
Only a type can be imported. sun.security.pkcs11.wrapper.CK_AES_CTR_PARAMS resolves to a package
I have windows 7 x64 with jdk 7x64 installed then replaced with jdk 7x32. I also made sure that my JAVA_HOME was set to the new jdk installation. I get the same problem when I run my application.
我安装了带有 jdk 7x64 的 Windows 7 x64,然后替换为 jdk 7x32。我还确保我的 JAVA_HOME 设置为新的 jdk 安装。当我运行我的应用程序时,我遇到了同样的问题。