Alex Rivera | Logout

Usefulness of JNI

Asked 2008-12-31T06:26:10.673
9

I've been a java developer for a couple years and have heard that you can do some pretty useful and powerful things with JNI. I don't know if I just haven't needed to use it or if it isn't terribly relevant to me; but I have not had to touch it at all.

I am wondering what the usefulness of this aspect of Java is. Examples would be great.

Edit
Report

2 Answers

4

I have written an extensive JNI layer for the iSeries to access DB2, user queues, data queues and a few other OS/400 specifics. Much of our system on the iSeries would have been impossible without JNI. So, yes, JNI has it's place, and when you need it, you really need it.

It's relatively difficult (next to pure Java), but powerful and not horrible.

Also, whenever I am looking at some JNI code, I also consider using JNA.

answered 2008-12-31T08:45:26.307
2

I can think of a few uses off the top of my head:

  1. integration with existing low-level (C/C++) APIs that do not have a Java counterpart
  2. integrating with aspects of the system that are not exposed through available Java APIs (direct hardware access, etc.)

Some might say it can be useful for creating highly-optimized sections of code however with modern JVMs you're getting pretty fast and the complications of using JNI would probably outweigh any performance benefit you might see.

answered 2008-12-31T06:52:25.410

Your Answer