55

Could anyone please help how do I solve this error:

Native code library failed to load.
java.lang.UnsatisfiedLinkError: no ts-jni in java.library.path

I am using IDEA IDE as a first time, and have been using Resin_4.0.37 as a server to test my work. As soon as I start my lcoal server in debug mode it stays for approximately 1-2 mins and then suddenly it drops down and get disconnected by giving me the above error.

I have set my Windows environmental variable correctly; and have also did the following in my IDE intelliJ:

 FILE->Project Structure->set Global Libraries->a. Java path and b. Resin library path.

Can any one please suggest me, what am I doing wrong and how do I set native library in intelliJ IDEA to solve the mentioned error.

Any help would be appreciated. Also do correct me if I am doing something wrong.

Thanks!

AKIWEB
  • 19,008
  • 67
  • 180
  • 294

1 Answers1

84

If you run your program from IntelliJ then you can set the java.library.path in the VM options input field in the Run/Debug Configurations dialog.

enter image description here

Example:

-Djava.library.path="C:\path\to\where\the\jni\lib\is"

CervEd
  • 3,306
  • 28
  • 25
maba
  • 47,113
  • 10
  • 108
  • 118
  • 3
    My project has many classes with main method. Is there any way to set that for the whole project? – Sri Harsha Chilakapati Jul 21 '14 at 14:39
  • 1
    @SriHarshaChilakapati, you can edit 'Defaults->Application->VM Options' to get what you want. After defining desired VM option in Defaults, every new run in the project will be created with that VM option. – GokcenG Aug 28 '14 at 11:15
  • what should we do If we need more than one library? -Djava.library.path="C:\qtjambi-4.8.6\lib,C:\qtjambi-4.8.6\bin" is legal? –  May 02 '15 at 16:02
  • 2
    @gurpinars On Windows I think you should separate with a semicolon ; and not a comma , – maba May 04 '15 at 17:09
  • FYI: with intellij 2017 - I have a large project where the JNI dlls are built from an external script that outputs the .dlls into a directory relative to the project root and I had to go into the MyRunConfig.xml file and manually edit it to put the library path into a directory relative to the project root, using ""$PROJECT_DIR$/../build/bin"" Is there a way to use the intellj UI to specify that the path is realtive and should not be expanded when the .xml is saved ? – peterk Apr 12 '17 at 16:12
  • This only works if the DLL does not need other DLL. In my case, my `JNI` DLL needs another `DLL` . – daparic Jun 06 '20 at 21:59
  • Thanks a lot the answer really helped – Sathiraumesh Jun 24 '20 at 12:30