0
我必須在應用程序中找到系統信息,爲此我有兩個本機庫文件,如下所示: SystemManagerLinux.so
和SystemManagerWin32.dll
。本機庫不在Java應用程序中加載
我必須在我的java代碼中使用這些庫文件來顯示關於java GUI的信息。我已經把這些文件上的位置:C:\Users\surjit\Documents\NetBeansProjects\SampleMonitor
,並給它是在我的NetBeans上運行選項IDE VM參數下面給出:
-Djava.library.path="C:\Users\surjit\Documents\NetBeansProjects\SampleMonitor"
,並調用庫中的代碼:
if (os.startsWith("Linux"))
loadTmpLibrary("SystemManagerLinux.so", "libSML", ".so");
else if (os.startsWith("Windows")) {
loadTmpLibrary("SystemManagerWin32.dll", "SMW", ".dll");
但是當我運行它給以下錯誤的應用程序:
Exception in thread "main" java.lang.UnsatisfiedLinkError: SystemManagerWin32.fetchProcessIDs([I)I
at SystemManagerWin32.fetchProcessIDs(Native Method)
at SystemMonitor.refreshPidList(SystemMonitor.java:168)
at SystemMonitor.<init>(SystemMonitor.java:383)
at SystemMonitor.main(SystemMonitor.java:494)
Exception in thread "Thread-2" java.lang.UnsatisfiedLinkError: SystemManagerWin32.fetchSystemMemoryStatus(LSystemMemoryStatus;)Z
at SystemManagerWin32.fetchSystemMemoryStatus(Native Method)
at SystemMonitor.run(SystemMonitor.java:410)
at java.lang.Thread.run(Thread.java:722)
請建議我solution.Thanks
'os'實際上以什麼開始? – EJP
os是一個字符串變量,它獲得如下所示的屬性os.name:String os = System.getProperty(「os.name」); – Surjit
使用JNA並完全跳過本機庫。 – technomage