Can i implemented JNI on already written C++ dllss

Hi,I am new to JNI. I have some dlls written in c++.can I use directly JNI on those dlls without changing the C++ code?. please let me know.Murali
[208 byte] By [balamuralid] at [2007-9-26 8:04:40]
# 1

The answer is "Yes, but no"!

o You can use the dlls as they are written.

o You will have to write one or more "wrapper" dll's that meet JNI calling-sequence requirements, and bridge to the existing dlls.

General procedure is

1. Define some nice java native methods that you would like to call to get the job done. (In other words, write the anaolg to the C/C++ functions, but make them nice java methods.)

2. Run javah on the results. This will generate an "h" file for the wrapper dll.

3. Write the wrapper dll to invoke the C functions, compile it, and link it.

bschauwe at 2007-7-1 18:25:45 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2
Hi bschauwe,Thank you very much.I will appreciate if you please let me know any documents or tutorials availabe in the second aproach which you mentioned. Regards,Murali
balamuralid at 2007-7-1 18:25:45 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 3
I have heard so much about the C wrapper, but never seen any code. The person who can give me an example of a very simple DLL wrapper, lets say for a delphi DLL, will get serious DUKE DOLLARS and will be an absolute HERO in my Books.IN OTHER WORDS PLEASE HELP
JonathanJ at 2007-7-1 18:25:45 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 4

Yes you can .

But some modification need to be done to your native source code in order to comunicate with java.

So, you must write some native methods into your java code first ( native methods are just like the other java methods except they have the "native" type in front of the metho's declaration ).

After you declare those methods you must implement them into your native source code ( C++) .

Then these native function writen in C++ can interact very well with the other methods in the DLL that you have.

Good luck !

ovi_cos at 2007-7-1 18:25:45 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 5
Some Example code ? !!!!
JonathanJ at 2007-7-1 18:25:45 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 6
Maybe this will help http://forum.java.sun.com/thread.jspforum=52&thread=174680
vindi1976 at 2007-7-1 18:25:45 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 7
sorry http://forum.java.sun.com/thread.jsp?forum=52&thread=174680
vindi1976 at 2007-7-1 18:25:45 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 8
and sorry again http://forum.java.sun.com/thread.jsp?forum=52&thread=184460
vindi1976 at 2007-7-1 18:25:45 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 9
Is there a site or book where I acn learn how to program a very simple Regular DLL in C / C++And then also a wrapper DLL ?
JonathanJ at 2007-7-1 18:25:46 > top of Java-index,Java HotSpot Virtual Machine,Specifications...