From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2af838e78888e2b2 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-12-08 12:08:35 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.cwix.com!rockie.attcanada.net!newsfeed.attcanada.net!204.127.161.4!wn4feed!worldnet.att.net!135.173.83.71!wnfilter1!worldnet-localpost!bgtnsc06-news.ops.worldnet.att.net.POSTED!not-for-mail Message-ID: <3C127350.A502B356@worldnet.att.net> From: James Rogers X-Mailer: Mozilla 4.76 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Java Bindings References: <3C116B97.9EA057A7@home.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Sat, 08 Dec 2001 20:08:34 GMT NNTP-Posting-Host: 12.86.33.222 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc06-news.ops.worldnet.att.net 1007842114 12.86.33.222 (Sat, 08 Dec 2001 20:08:34 GMT) NNTP-Posting-Date: Sat, 08 Dec 2001 20:08:34 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:17630 Date: 2001-12-08T20:08:34+00:00 List-Id: > > Native Ada from Java: don't remember, can't find it. > Following the JNI (Java Native Interface) rules, you would need to create a C program as a wrapper to call the Ada library. The C wrapper must be compiled as a DLL (WIN32) or Shared Object (Unix, Linux). The C wrapper must include the C header file generated by the javah program based upon the Java "wrapper" class defining the Java view of the method(s) to be called. The Java view of interfacing to other languages is that the other language must perform all the conversions to Java. Java remains ignorant of other language issues. For instance, there is NO Java equivalent to Ada's Convention parameter to the Ada Import statement. A simple example just between C and Java: 1) Create the Java "wrapper" class: public class Thing { public native void displayThing(); static { System.loadLibrary("thing"); } } 2) Run "javah Thing" to generate the appropriate C header file: The resulting header file follows: /* DO NOT EDIT THIS FILE - it is machine generated */ #include /* Header for class Thing */ #ifndef _Included_Thing #define _Included_Thing #ifdef __cplusplus extern "C" { #endif /* * Class: Thing * Method: displayThing * Signature: ()V */ JNIEXPORT void JNICALL Java_Thing_displayThing (JNIEnv *, jobject); #ifdef __cplusplus } #endif #endif 3) Create the C implementation of the method(s) defined in the Java "wrapper" class: #include "Thing.h" #include JNIEXPORT void JNICALL Java_Thing_displayThing (JNIEnv *, jobject) { printf("This is the thing\n"); return; } 4) Compile the C code to a shared object or dll You also need to put the resulting C library file in a directory named in the PATH variable in NT or the LD_LIBRARY_PATH in Unix. 5) Create a Java program to instantiate the wrapper class and call the native method. Jim Rogers Colorado Springs, Colorado USA