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

我有這些錯誤我該如何解決它。 一些用戶可以訪問這些並沒有問題,但有些用戶不能。JNativeHook_6363198016012433909.dll:訪問被拒絕

回答

3

這是一個奇怪的隨機錯誤,有時會在Windows 7和Windows 8上顯示出來。一切都很好,然後當Java嘗試訪問臨時文件夾中的DLL時突然出現拒絕訪問異常。

我發現刪除TEMP文件夾並讓它自動重新創建它通常可以解決問題。

如果您是將該DLL放入TEMP文件夾的代碼的作者,那麼我會建議您更改將該DLL放在此路徑下的文件夾中的代碼,因爲我尚未在此處看到此問題:% USERPROFILE%\ AppData \ Local \

我在某處讀到這可能是由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()); 
    } 
+0

是的,謝謝我會試試這個 – kelvz 2014-02-28 09:14:31