【问题标题】:Java getting error 'Unhandled exception type XYZ'Java 收到错误“未处理的异常类型 XYZ”
【发布时间】:2012-06-08 22:42:19
【问题描述】:

我有这个代码:

class Crypt
{
    Key KEY;
    String TD;
    Cipher aes = Cipher.getInstance("AES/CBC/PKCS5Padding");

    KeyGenerator keyGen = KeyGenerator.getInstance("AES");

public Crypt()
{
    int keyLength = 192;
    keyGen.init(keyLength);
    KEY = keyGen.generateKey();

编译时出现此错误:

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    Unhandled exception type NoSuchAlgorithmException
    Unhandled exception type NoSuchPaddingException
    Unhandled exception type NoSuchAlgorithmException

在研究错误时,我发现了this。但是在下载、安装和verifying 无限强度管辖政策文件是最新的之后,我仍然收到错误。

【问题讨论】:

  • 只是想对其他 osx 用户发出警告。在我看来,如果您从 java 的网站手动更新它们,您最终可能会遇到其他错误。内置的应该可以工作

标签: java macos jce


【解决方案1】:

您的错误非常清楚,与无限制权限加密文件无关。它告诉你有未处理的检查异常。

throws Exception 添加到您的构造函数中,如下所示:

public Crypt() throws Exception
{
    int keyLength = 192;
    keyGen.init(keyLength);
    KEY = keyGen.generateKey();

【讨论】:

    【解决方案2】:

    您是否也将它们安装到 /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/security 中?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-04
      相关资源
      最近更新 更多