25

I'm using PDE to run a Processing sketch, and I get the following error:

Verify that the java.library.path property is correctly set.

Could anyone of you tell me how to solve this problem?

Alba Mendez
  • 4,321
  • 1
  • 37
  • 52
Haiyuan Zhang
  • 38,486
  • 40
  • 103
  • 133

5 Answers5

46

You can set it on the command line thus:

java -Djava.library.path=... <existing arguments (classpath, name of class to run etc.)>

and point it to the directory containing the relevant library.

Per Lundberg
  • 3,409
  • 1
  • 33
  • 44
Brian Agnew
  • 261,477
  • 36
  • 323
  • 432
  • 6
    This isn't working for me. I tried `java -Djava.library.path=C:\Python33` but it gave me the usage of `java.exe` – papaiatis Jul 11 '13 at 13:45
  • 3
    @papaiatis You still have to specify the name of the class to run. The `-D` is in addition to what you normally specify when running a java from the command-line. – Andreas Jan 26 '17 at 18:19
  • Thanks @Andreas, I edited the answer to make this somewhat clearer. – Per Lundberg Apr 07 '22 at 08:08
12

In Eclipse, I did this to get OpenCV working:

  1. In the Run menu, select Run Configuration.
  2. Go to the (x)=Arguments tab of your sketch.
  3. Add this in the VM arguments field:

    -Djava.library.path="/path/to/OpenCV/library"
    
Alba Mendez
  • 4,321
  • 1
  • 37
  • 52
9

Before System.loadLibrary(""), use the following code to check you java.library.path

System.out.println(System.getProperty("java.library.path"));

Generally,the java.library.path=/usr/java/packages/lib/i386:/usr/lib/jni:/lib:/usr/lib

Provides several options for:

  • $ sudo cp libxxx.so /usr/lib/jni
  • java -Djava.library.path=path of so xxx
caopeng
  • 826
  • 13
  • 22
  • 1
    Instead of changing your source code, you use the Expressions tab in the debug perspective and put System.getProperty("java.library.path") to show you what it's value is. – Captain Charmi Sep 18 '13 at 12:22
6

Your library.path is fine, what you need to do is to drop prefix lib and suffix .so from your System.loadLibrary( "..." ). On Linux or "linux-android" those will be automatically added by JVM.

Kalle Richter
  • 7,146
  • 22
  • 65
  • 152
user3048370
  • 61
  • 1
  • 1
0

Conclustion of above all answers (short form) is as follows:

Lets say my lib folder path is lib/

Then to add in the library path: run below command:

java -Djava.library.path=lib/ -jar  mySampleJar.jar
Hafiz Muhammad Shafiq
  • 7,551
  • 11
  • 57
  • 106