2012-07-26 24 views
1

我在ubuntu上運行我的第一個程序。在ubuntu中運行JNI程序

但有一個錯誤,當我試圖運行它:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no foo in java.library.path 
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1681) 
    at java.lang.Runtime.loadLibrary0(Runtime.java:840) 
    at java.lang.System.loadLibrary(System.java:1047) 
    at JNIFoo.<clinit>(JNIFoo.java:6) 
    Could not find the main class: JNIFoo. Program will exit.  

回答

2

這些線

確保本地庫駐留在目錄中的一個 本地庫路徑。如果您在Solaris系統上運行,則使用 LD_LIBRARY_PATH環境變量來定義本機 庫路徑。確保它包含包含libHelloWorld.so文件的目錄 的名稱。如果libHelloWorld.so文件 是在當前目錄下,你可以發出以下兩個命令 在標準shell(SH)或KornShell(KSH)建立正確的 LD_LIBRARY_PATH環境變量:

LD_LIBRARY_PATH=. 
export LD_LIBRARY_PATH