[program-java] Re: Is there a JNI Mailing list? [john.boyer@xxxxxxxxxxxxxxxxx: Telling Java where to find a native library]

  • From: "J. R. Westmoreland" <jr@xxxxxxx>
  • To: <program-java@xxxxxxxxxxxxx>
  • Date: Tue, 24 Aug 2010 09:02:47 -0600

About six months ago I did a JNI module where I used a number of libraries
that were native C++. It worked but one has to be careful with parameter
checking and type conversion etc. The application works fine. If I can
answer questions let me know.

J. R.


-----Original Message-----
From: program-java-bounce@xxxxxxxxxxxxx
[mailto:program-java-bounce@xxxxxxxxxxxxx] On Behalf Of John J. Boyer
Sent: Tuesday, August 24, 2010 6:28 AM
To: programmingblind@xxxxxxxxxxxxx
Subject: [program-java] Re: Is there a JNI Mailing list?
[john.boyer@xxxxxxxxxxxxxxxxx: Telling Java where to find a native library]

Thanks. I do alkready have the C code for the bindings. I'll try some things
for compiling it as a shared library. I've looked an JNA, but I'm a C guy,
so I wanted to give JNI a shot. Thre BrailleBlaster application has several
other C libraries, so JNA might be the best choice in the long run.

John

On Tue, Aug 24, 2010 at 02:00:41PM +0200, QuentinC wrote:
>    > I may switch to the Sun JDK at some point, but right now i just want
to
>    get the bindings to load the library, so I can proceed with testing.
>    These bindings will be used with other jdk's, inncluding Eclipse.
Prrefer
>    to work in a command-line environment.
>    Eclipse is not a JDK but an IDE.
> 
>    I'm sure you will have much less problems if you switch immediately to
the
>    official sun JDK.
>    For example on debian and ubuntu , OpenJDK is really a pain. There are
>    many topics about various java problems on a french forum I regularely
go,
>    and they are solved by magic just after they switch without doing
anything
>    else.
> 
>    > The C part of the bindings includes jni.h Will this take care of the
>    necesary entry poiints for Java?
> 
>    If the developper has included jni.h and exported functions whose names
>    start with java, yes, it's read for use by java. You have to compile it
as
>    a shared library.
>    I had a complete compilation procedure for windows using MinGW, hopes
that
>    helps. I have infortunately never done JNI outside of windows, so I
don't
>    know if it works for other systems.
>    1 - Compile java class
>    2 - generate C header using javah on the compiled java class
>    3 - Code C functions using the generated header at step 2
>    4 - Make a .def file listing all exported functions
>    5 - Compile C source => gcc -o file.o file.c
>    6 - Compile shared library => gcc -shared -o file.dll file.def file.c
>    I think you can try to start at step 4, if somebody gave you the source
of
>    a java compatible library.
> 
>    Just a note : I personally don't use JNI anymore. You may look at JNA,
>    which is much easier in case you haven't already a wrapper.
> 

--
John J. Boyer; President, Chief Software Developer Abilitiessoft, Inc.
http://www.abilitiessoft.com
Madison, Wisconsin USA
Developing software for people with disabilities



Other related posts: