Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Intro to using JNI with Eclipse?
Intro to using JNI with Eclipse? [message #328247] Mon, 19 May 2008 21:37 Go to next message
Eclipse User
Originally posted by: qabuzhd02.sneakemail.com

Is there any sort of tutorial introduction to using JNI with Eclipse?
(I'm developing an app with the platform-independent heavy lifting in C++
and the UI in Java, and JNI in between. I use a Mac for development.)
I've looked around eclipse.org, and can't find anything that really looks
like it would get me up and running.

What do people think of the feasibility of using Eclipse to develop
JNI-based code? From my five or ten minutes of searching on eclipse.org
I've found a couple of tools geared towards JNI -- but they seem to be
mostly in beta, and there doesn't seem to be any single unifying approach
to JNI.

I have a good deal of experience with using Eclipse for Java, but almost
none with CDT. Any suggestions would be much appreciated. I've been
beating my head against Xcode and its quirks, and my brain is getting
pretty sore, so I'm really hoping that Eclipse will be a viable
alternative.
Re: Intro to using JNI with Eclipse? [message #328248 is a reply to message #328247] Tue, 20 May 2008 01:05 Go to previous message
Eclipse User
Originally posted by: totolaricot.mac.com

Jonathan wrote:
> Is there any sort of tutorial introduction to using JNI with Eclipse?
> (I'm developing an app with the platform-independent heavy lifting in
> C++ and the UI in Java, and JNI in between. I use a Mac for
> development.) I've looked around eclipse.org, and can't find anything
> that really looks like it would get me up and running.
>
> What do people think of the feasibility of using Eclipse to develop
> JNI-based code? From my five or ten minutes of searching on
> eclipse.org I've found a couple of tools geared towards JNI -- but
> they seem to be mostly in beta, and there doesn't seem to be any
> single unifying approach to JNI.
>
> I have a good deal of experience with using Eclipse for Java, but
> almost none with CDT. Any suggestions would be much appreciated.
> I've been beating my head against Xcode and its quirks, and my brain
> is getting pretty sore, so I'm really hoping that Eclipse will be a
> viable alternative.
>
>
doing JNI work is pretty straight forward, with or without eclipse..
after all it's just plain C/C++ with some added conventions. if you
want inspiration on how to structure your project, you could look at how
the SWT team organized their project (keep in mind that some of the
added complexity is just because they had to deal with more platforms).

you could also give JNA a shot if you want to quickly create a proof of
concept binding for your C++ library without having to answer your
question. If you don't mind writting weird looking Java code, you can
also venture into GlueGen or JNIgenerator to generate your binding (that
would simplify the task of dealing with JNI): the former is the binding
generator created for JOGL (roughly speaking it is a C/C++ header
preprocessor that can generate the JNI code for you); the latter is the
equivalent solution created by the SWT team (I find it a lot easier to
use than GlueGen - however you have to do more manual labor as it does
not process the C headers). I also used SWISH in the past to quickly
generate some JNI code for a reasonably simple class library that had
250 Java classes. SWISH is also a header preprocessor, and once you get
over the limitations of the preprocessor you can make the binding
generation a part of your build process to automate the process anytime
you make C/C++ code changes. The added benefit of SWISH is that you can
generate multiple language bindings from the same configuration files (I
generated a perl and Java binding for another library).

In the end, there is little reason these days to write too much JNI code
manually (especially when dealing with large native libraries)... unless
of course you have the time and someone paying for it... Altogether,
SWISH was the simplest to use (got the job done is a couple days with no
prior experience). For quick and dirty without pain, I use JNA (I
recently worked on supporting the Carbon native toolbar in java by
prototyping the code with JNA before I migrated it to SWT/JNIgenerator).

--
Laurent Mihalkovic, co-author SWT/JFace in Action (www.manning.com/scarpino)
Previous Topic:Package View
Next Topic:Eclipse version
Goto Forum:
  


Current Time: Sat Aug 30 16:44:41 EDT 2014

Powered by FUDForum. Page generated in 0.07154 seconds