Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Using DLL file in Java Program

843829Mar 11 2003 — edited Mar 19 2003
hi

my problem is
i dont want to create a dll file instead want to use a already existing dll file

i have a dll file and it has some functions in it.

i want to load that dll file into java class and use those functions.

for eg assume dll file has a method "add" which takes 2 integers and adds them returns the result.

dll method-
# int add(int x,int y) // i want to use this method in my java class

i wrote the following code

//java class
class test
{
native int add(int x, int y);
static
{
System.loadLibrary("dllfilename");
}
public static void main(String s[])
{
test t = new test();
int i = t.add(10,20);
System.out.println("result: "+i);
}
}

Dont think that if i want to add two numbers then why to go for dll,
There are many other complex functions in dll file and i want to use them.

i could not succeed with the above program. I saved dll and java file in same location. System.loadLibrary is loading my dll file but giving unsatisfied link error.

i am sure it is loading the file because if i remove the dll file from this folder it is giving no dll file in library path error,so it is loading dll file but not executing the function.

can any one help me.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 16 2003
Added on Mar 11 2003
11 comments
3,128 views