26

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,432
  • 1
  • 39
  • 55
Haiyuan Zhang
  • 40,802
  • 41
  • 107
  • 134

5 Answers5

48

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,837
  • 1
  • 36
  • 46
Brian Agnew
  • 268,207
  • 37
  • 334
  • 440
  • 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
  • 4
    @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
14

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
J. Scott Elblein
  • 4,013
  • 15
  • 58
  • 94
caopeng
  • 914
  • 13
  • 23
  • 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
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,432
  • 1
  • 39
  • 55
7

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
  • 8,008
  • 26
  • 77
  • 177
user3048370
  • 71
  • 1
  • 1
0

Conclusion 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
J. Scott Elblein
  • 4,013
  • 15
  • 58
  • 94
Hafiz Muhammad Shafiq
  • 8,168
  • 12
  • 63
  • 121