JNativeHook_6363198016012433909.dll:访问被拒绝

时间:2013-05-02 05:47:22

标签: java dll

Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: C:\Users\Kelvz1\AppData\Local\Temp\JNativeHook_6363198016012433909.dll: Access is denied

我有这些错误如何修复它。 有些用户可以访问这些并没有问题,但有些用户无法访问。

1 个答案:

答案 0 :(得分:3)

这是一个奇怪的随机错误,有时会出现在Windows 7和Windows 8上。有一天一切都很好,然后当Java尝试访问临时文件夹中的DLL时突然出现访问被拒绝的异常。

我发现删除TEMP文件夹并让它自动重新创建它通常可以解决问题。

如果您是将DLL放入TEMP文件夹的代码的作者,那么我建议您更改代码以将DLL放在此路径下的文件夹中,因为我还没有看到这个问题:%USERPROFILE %\应用程序数据\本地\

我在某处看到这可能是由Microsoft Security Essentials引起的,但它看起来并不像刚刚遇到此问题的计算机上安装的那样。

我见过这种情况发生在很多不同的DLL文件中,比如jna.dll。

如果您正在使用JNA并且它有此问题,您可以更改临时目录系统属性,JNA将在不同的目录中创建该文件。此代码应该适用于此。

    String osName = System.getProperty("os.name");
    if (osName.toLowerCase().startsWith("windows")) {
        // we change the temp directory because sometimes Windows is stupid and doesn't want to load jna.dll from the temp directory
        File tempDir = new File(System.getenv("USERPROFILE") + "\\AppData\\Local\\MyCompany\\temp");
        System.out.println("Using temp dir: " + tempDir.getPath());
        tempDir.mkdirs();
        System.setProperty("java.io.tmpdir", tempDir.getPath());
    }