Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Not able to find .dll file in my java path

 
Sindhura Lakshmi
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,


I am using JNI concept for writing data into an image .I was able to do this using a normal java class(Java Project).
Now i was trying to integrate it into my webproject.when i am invoking my method it is not able to load the native library .
I am getting the following exception:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no chilkat in java.library.path

Can i add the dll file in any of the jars ?How can i do this?Please help .

Thanks
Sindhura


 
Prashant Hurria
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The .dll files will not be picked from the class path.
You can set the enviornment variable java.library.path=<Path Of Files >
eg if your dlls are ket in the folder /home/nagarro/official/jNotify/jnotify-lib-0.93 you can set it as java.library.path=/home/nagarro/official/jNotify/jnotify-lib-0.93
alternativally you can also run it like this java -Djava.library.path=/home/nagarro/official/jNotify/jnotify-lib-0.93
 
Sindhura Lakshmi
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Prashanth

But how i can keep my dll file in my web project , so that doesnt give any exception when we run it on any another machine.
I understood that we should set it in the path .But how can i include it in my application without setting it every time.
 
Prashant Hurria
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think what will work is that before you deploy the application set the java.library.path as an environment variable.
 
Sindhura Lakshmi
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes if i put it in my java path it works fine.But when my application will be deployed on a linux server where can i include this .dll.
 
Prashant Hurria
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Set it as an Enviornment variable like this
SET java.library.path=Path of your DLL
 
Sindhura Lakshmi
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want my dll file to be available at runtime to the application.As suggested if i place in the java .library path in environmental variables it works only on my system but i think it does not work on all platforms i.e if i deploy the application on linux server.
 
Prashant Hurria
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am afraid that is the only way.At least what I know of. I could not find anything else. You can try entering information in Manifest file or something like that. Once i made it work the way i mentioned above i didint try much as I didnt need.
 
Rob Spoor
Sheriff
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't use DLL files in Linux, but the java.library.path variable works on all systems. The only difference is that in Linux you will need to use : instead of ; between two folders.
 
Prashant Hurria
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:You can't use DLL files in Linux, but the java.library.path variable works on all systems. The only difference is that in Linux you will need to use : instead of ; between two folders.

Exactly .... for Linux you need a equivalent of the .dll and that would be a .so file. Most distributions include a .dll and a .so file. For example popular opensource projects using JNI like jnotify provide you with both a .dll filefor windows and a .so file for linux
 
Srinivas Kothuri
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i too was facing the same problem but is resolved by adding the folder path (containing my dll) to PATH env. variable on windows.
but now the message for exception is changed to

Exception in thread "main" java.lang.UnsatisfiedLinkError: NativeClass.nativeMethod(I)I
at NativeClass.nativeMethod(Native Method)
at NativeClass.<init>(NativeClassClass.java:17)
at NativeClassTest.main(NativeClassTest.java:14)


please notice that NativeClass.java is containing my native method and NativeClassTest.java is the class to contain my main() method.
If the dll is not properly formed, how can I find it.
how would i know that System.loadLibrary ("mydll"); is failed?

kindly give me some clues . ..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic