How to set the java.library.path in intelliJ Idea
Asked Answered
A

1

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!

Allayne answered 10/10, 2013 at 23:39 Comment(0)
L
85

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"

Lavena answered 11/10, 2013 at 6:53 Comment(7)
My project has many classes with main method. Is there any way to set that for the whole project?Almswoman
@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.Curiosity
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?Staciastacie
@gurpinars On Windows I think you should separate with a semicolon ; and not a comma ,Lavena
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 ?Toaster
This only works if the DLL does not need other DLL. In my case, my JNI DLL needs another DLL .Washable
Thanks a lot the answer really helpedEudemonia

© 2022 - 2024 — McMap. All rights reserved.