× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



The all-important link between the JVM, and the native method you are
trying to call, is the name of the native method.  The name exported by
your service program must exactly match the name expected by the JVM, or
you'll get one of these call-time (as opposed to load-time)
UnsatisfiedLinkError things thrown at you.

Again, the name that is "manufactured" by the JVM (the caller side) must
match *exactly* the name that is exported from MYSRVPGM (the callee).

To see the name that Java will manufacture

   Start a QSH session and type

      javah -jni fully.qualified.class.name

   ...where 'fully.qualified.class.name' is the name of your class (withOUT
   the '.class' on the end.)  Presuming all goes well, this will create a
   file in the current directory called fully_qualified_class_name.h that
   includes the "name" that the JVM will be using to get to the native
   method.

   For instance,

      javah -jni java.lang.String

   ...results in the file java_lang_String.h

   Now, java.lang.String does specify a native method, "intern()" and the
   section of this header file describing it looks like:

      /*
       * Class:     java_lang_String
       * Method:    intern
       * Signature: ()Ljava/lang/String;
       */
      JNIEXPORT jstring JNICALL Java_java_lang_String_intern
        (JNIEnv *, jobject);

   The all-important part is the part after JNICALL -- the
   Java_java_lang_String_intern -- this is the name a native method library
   (a/k/a service program) designed to "handle" this native method has to
   export, in order to make the connection.

To see the names exported by MYSRVPGM you can run this command:

      DSPSRVPGM SRVPGM(MYSRVPGM) DETAIL(*PROCEXP)


HTH.

-blair

Blair Wyman -- iSeries JVM -- (507) 253-2891
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Think as you work, for in the final analysis, your worth to your
  company comes not only in solving problems, but also in
  anticipating them."  -- Tom Lehrer



                                                                           
             Peter.Daransky@am                                             
             bos.at                                                        
             Sent by:                                                   To 
             java400-l-bounces         Java Programming on and around the  
             @midrange.com             iSeries / AS400                     
                                       <java400-l@xxxxxxxxxxxx>            
                                                                        cc 
             03/12/2004 06:12                                              
             AM                                                    Subject 
                                       JNI Problem                         
                                                                           
             Please respond to                                             
             Java Programming                                              
             on and around the                                             
              iSeries / AS400                                              
                                                                           
                                                                           




Hi,

i've a little problem to start JNI Program on OS/400 (V5R2). I've wroted
small Java program wich should call a native function from ServiceProgram
...
The code is very simple and stage "static {
System.loadLibrary("MYSRVPGM"); }"  seems to me thath works ok ! Also no
errors !?
But if i call the native function i'll always got a
java.lang.UnsatisfiedLinkError() ... and i've tryed all possibilities with
variables like -Djava.library.path etc., everything what i found in manual
...

Has someone any idea ?

Regards

Peter Daransky
AMBOS EDV-Beratungs GesmbH
Dauphinestr. 44
A-4020 LINZ               Austria
Tel:         +43-732-312919-0
Fax:        +43-732-312919-20
e-mail:  Peter.Daransky@xxxxxxxx
Homepage: http://www.ambos.at
_______________________________________________
This is the Java Programming on and around the iSeries / AS400 (JAVA400-L)
mailing list
To post a message email: JAVA400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/java400-l
or email: JAVA400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/java400-l.





As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.