Re: JNI Woes



Gordon Beaton wrote:

On 30 Oct 2006 06:00:39 -0800, ShadowPhoenix wrote:
I am trying to call functions on the dll from Java, but all the things
I have read include running javah on the class file (which I can
successfully do), but it doesn't seem to help because I don't have
access to the source code, so I can't really use the header file.

Writing a wrapper library to implement the functions from the dll to
specifically work with Java (including jni.h, etc) is not at all
feasible because there are hundreds and hundreds of functions, and I
don't have enough time to write a library for them all.

Unfortunately for you, the technical reality of things doesn't care
how much time you've got, and Java does not offer any other technical
solutions. You can't invoke arbitrary C functions from a Java
application. The library must have been written to be used from Java,
wrapped suitably, or moved to a separate process that you communicate
with using other mechanisms.

Consider that using JNI doesn't necessarily mean that you need to wrap
your functions on a 1:1 basis. Choose a suitable place for your JNI
boundary, e.g. by moving it to a higher abstraction level you might
get a smaller contact area.

Or perhaps you don't really need all of those hundreds and hundreds of
functions. You only need to write wrappers for the stuff actually used
by your application.

There might also be some commercial products that can automate the
wrapping.

http://www.excelsior-usa.com/xfunction.html

might suite the OP's needs.

/gordon


--
Bill Medland
.



Relevant Pages

  • Re: JNI Woes
    ... I have read include running javah on the class file (which I can ... Writing a wrapper library to implement the functions from the dll to ... and Java does not offer any other technical ... Choose a suitable place for your JNI ...
    (comp.lang.java.programmer)
  • Re: BigInteger enhancing
    ... has all sorts of methods useful for cryptography, but is written in C - ... you'd have to write a wrapper using JNI, or else copy the java-GMP bridge ... AFAIR GMP was also used with SUN's Java until it was replaced ...
    (comp.lang.java.programmer)
  • JNI_CreateJavaVM, class loading and jre/lib/ext directory
    ... which creates a VM and use some Java classes. ... class object using JNI call, where all, the .class file will be ...
    (comp.lang.java.programmer)
  • Share library calls from java and c code results are different
    ... java. ... So I have prepared a java (JNI) wrapper using the swig tool and ...
    (comp.lang.java.programmer)
  • Re: JNI - Passing and returning complex values
    ... |> |> This is one of the uglier parts of Java. ... You have to write a very thin C wrapper which calls the C ... The trick is to write a reference to the wrapped ... ~ private long getCPtrAndAddLeftDaughterReference(mgTreeNode daughter) { ...
    (comp.lang.java.programmer)