Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

DLL in java code?

  Asked By: Almas    Date: Aug 14    Category: Java    Views: 839
  

How to call any DLL in java code?

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Anselma Schmidt     Answered On: Aug 14

use JNI......................................

 
Answer #2    Answered By: Dang Tran     Answered On: Aug 14

You need to use JNI (Java Native Interface). This API
enable developers to use platform specific features
and also functionality integrated in Shared objects
(Linux) and Dynamic Link Libraries (Windows).

Take a look at
java.sun.com/.../jni.html.

 
Answer #3    Answered By: Jamie Roberts     Answered On: Aug 14

You can refer to JNI tutorial on sun web site.
Fitsr load library.
Then call  the required method.
Take acre the the dll  must be in path OR keep it in Win32 folder of system


public class Test {
// Load the dll that exports functions callable from java
static {System.loadLibrary("TestImp");}

// Imported function declarations
public native void print(String msg);

public void Test() {
}
public static void main (String ar[]){


Test t = new Test();
// Printf example
t.print("->Testing JNI - Hello from java  to c++\n");

}
}

 
Didn't find what you were looking for? Find more on DLL in java code? Or get search suggestion and latest updates.




Tagged: