2 Replies Latest reply: Jan 25, 2011 2:32 PM by 834162 RSS

    How to invoke native "_Java_*" methods?

      I have a dll with few methods I'd like to call. Problem is I don't have any API for it.
      I'm using Dll Export Viewer to see what functions are available.
      Most of the functions have signature like this:
      There is one which is just called:
      I'm using JNA to load and invoke dll methods. When I invoke the testMethod it works just fine, so I assume that the dll lib is loaded properly. Problem is with other methods. I can't call them using full "_Java_something_MethodName" or just "MethodName". Is it a diffrent type of method, is it somewhere else not in the loaded dll, is there diffrent way to invoke such method?

      Please help :)

      The Exception thrown when trying to invoke those methods is:
      java.lang.UnsatisfiedLinkError: Error looking up function 'MethodName':  
        • 1. Re: How to invoke native "_Java_*" methods?
          Looks like a JNI method.
          is there diffrent way to invoke such method?
          Yes - java.

          Java calls JNI.

          JNA calls methods (not JNI.) There is no reason that JNA can't 'call' the method but the code in the method is written with the expectation that Java is going to call it. And at a minimum it would be difficult to coerce JNA into correctly calling it (passing java data rather than C data.) Might not be possible at all.
          • 2. Re: How to invoke native "_Java_*" methods?
            Thanks for the reply.

            How to call JNI? When I'm doing something like this:
                 public void init() {
                 public native String GetSystemDir();
            it still throws
             java.lang.UnsatisfiedLinkError: test.Native.GetSystemDir()Ljava/lang/String

            After few tries my code doesn't throw the Exception. Is it true that if I have a JNI method called Javasomething_MethodName than my Java class wich calls the native method "MethodName" must be named "Something"?

            I know it might be a stupid question but I'm totally new to JNI stuff, but after I renamed my class it doesn't throw the Exception.

            Edited by: user8628318 on 2011-01-25 12:31