Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure .dll file in Java?

I am using Jacob jar file in my java application.

This Jacob jar file comes with a .dll file. I have added Jacob jar file to my classpath. But when I execute my application a runtime error occurs as

"couldn't load jacob-1.15-M3-x86.dll file"

How can I load this .dll file?

Edited:=================================================================================

I had set the "path" environment varaible to the dir that contains my .dll file and loading that .dll file as follows

static {
    System.loadLibrary("jacob-1.15-M3-x86.dll");
}

but the following error occured

    java.lang.UnsatisfiedLinkError: no jacob-1.15-M3-x86.dll in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1734)
    at java.lang.Runtime.loadLibrary0(Runtime.java:823)
    at java.lang.System.loadLibrary(System.java:1028)
    at TemplateClass.TemplateClass.<clinit>(TemplateClass.java:14)
like image 844
Yatendra Avatar asked Jan 17 '10 18:01

Yatendra


1 Answers

The 'jacob-1.15-M3-x86.dll' needs to be in a place where your the operating system can find it. You have a few options here:

  • You can place the .dll file in the directory you started your application from. If you have a batch script to start your application, it would be that directory. If you are starting in some sort of application server, it would typically be the 'bin' directory.

  • You can place the .dll file somewhere in the %PATH% environment variable. I may be easier to just update your PATH environment variable to include the directory that contains your .dll file.

  • Another option is to place your .dll into the %SystemRoot%\system32 directory. Usually this is 'C:\Windows\system32'. This option is not usually recommended unless it is a shared library like the MSCVRT runtime.

One other possible issue you might have. If the .dll is compiled as 32-bit, then you must be running in the 32-bit Java runtime. Likewise, if it is a 64-bit .dll it needs to be run in a 64-bit JRE.

like image 99
Chris Dail Avatar answered Sep 18 '22 13:09

Chris Dail