see if it helps for You:-
You can do it as long as you have an API to the third party DLL. All you have to do is to
create your own DLL which contains native implementations of Java methods where C or C++
routines will have signatures generated by javah. All those routines would do is to invoke
the appropriate functions in the target DLL with known API. I did it earlier for ODBC
(where ODBC driver manager was the third party DLL) and we created our own DLL calling the
ODBC methods.
Comment
From: angelany
Date: Thursday, September 17 1998 - 10:26AM PDT
msmolyak,
Thanks for your answer. There are still a few things that I
don't quite understand. Would you please elaborate a little more?
Suppose I have these files:
test.dll -- the core dll file
TestMain.java -- the test application in Java, it calls class and methods in "Rate.java"
Rate.java -- the Java file that contains definition of native methods
Rate.h -- generated by "javah -jni Rate.java"
Rate.c -- generated by "javah -stubs Rate.java"
Now, should I write a code called something like "RateImp.c"
to implement all the signatures in "Rate.h"? How are the Java
specific types handled? How does the "Rate.c" come into play?
Thanks.
Angelany
Comment
From: msmolyak
Date: Thursday, September 17 1998 - 10:33AM PDT
First of all you do need stubs if you are using JNI, stubs were needed for the old native
interface. Thus you just take Rate.h and create a C file (e.g., RateImp.c) where you will
implement the methods according to their signatures. You do not need your Rate.c
Comment
From: angelany
Date: Friday, September 18 1998 - 09:48AM PDT
Hi msmolyan,
I still have trouble passing data types to and from Java.
Could you please give an example on passing an object and
a string? Thanks a lot.
Angelany
Comment
From: msmolyak
Date: Friday, September 18 1998 - 10:41AM PDT
Here is an example. The first two parameters (JNIEnv and jobject) are present in all teh calls. The first is the environment, the second is pointer to the invoker object. In this example I pass file name as a parameter and convert it from Java string to C string. Then I invoke a C function using that string.
Go to the JNI Spec and tutorial on Javasoft's Web site, a lot of useful info.
/**
* This function opens specified configuration file for reading or writing.
*/
JNIEXPORT void JNICALL Java_com_excalib_rw_CfgObj
(JNIEnv * env, jobject obj, jstring jFileName)
{
char *cfgFileName;
// Convert Java string to C string
cfgFileName = (*env)->GetStringUTFChars(
// Call RetrievalWare API function openning configuration file.
cq_open_conquest_cfg(cfgFi
}
Main Topics
Browse All Topics





by: ravindra76Posted on 2000-06-04 at 23:40:24ID: 2889711
look
uting.com/ unixreview /backissu/ 9707/ 9707f 1.htm
ooks/tutor ial/native 1.1/index. html oks/157521 1025/ch30. htm a/iss1/jav an.htm emos/javaw n/native.h tml com/viewso urce/
com/java/J NI/index.s htm oy/Courses /Advanced/ units/jni/ /native/
avatips/jw -javatip17 .html avaworld/j w-10-1999/ jw-10-jni- 2.html avaworld/j w-07-1997/ jw-07- java dev.html
http://www.performancecomp
http://java.sun.com/docs/b
http://www.pbs.mcp.com/ebo
http://www.sys-con.com/jav
http://bogart.sip.ucm.es/d
http://developer.netscape.
http://codeguru.developer.
http://www.cs.pdx.edu/~ant
http://www.swtech.com/java
Java Tip 17: Integrating Java with C++
http://www.javaworld.com/j
Enhance your Java application with Java Native Interface (JNI)
http://www.javaworld.com/j
Use native methods to expand the Java environment
http://www.javaworld.com/j