Can someone tell me, how one can do native programming?
Gordon Beaton - 16 Nov 2005 06:44 GMT
> Can someone tell me, how one can do native programming?
The short description:
- write your java code, declaring one or more methods "native" and
making sure the shared library that will contain the native methods
is loaded before any native methods are invoked
- compile the java code
- run javah to get a header file containing native declarations of the
native methods
- implement the native methods in e.g. C or C++ (or really any
language with a C binding), using the header file as reference
- compile your native code to a shared library or DLL and put it where
the JVM can find it, i.e. one of the places mentioned in
java.library.path
If you want a more detailed explanation, start reading:
http://www.amazon.com/exec/obidos/ASIN/0201325772
http://www.amazon.com/exec/obidos/ASIN/0136798950
http://java.sun.com/docs/books/tutorial/native1.1/index.html
http://java.sun.com/j2se/1.5.0/docs/guide/jni/index.html
/gordon

Signature
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
Vitaly - 16 Nov 2005 10:02 GMT
If you use MS VC++ v7.1 you can test the tool at
http://simtel.net/product.php[id]90910[SiteID]simtel.net
> Can someone tell me, how one can do native programming?
Roedy Green - 16 Nov 2005 10:11 GMT
>Can someone tell me, how one can do native programming?
see http://mindprod.com/jgloss/jni.html
Learn C/C++
Get a textbook on JNI

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.