Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JNI versus CORBA  RSS feed

 
Kimberly Shu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a big application implemented in C, and I need to invoke the methods (actually to run the main method of the C application) in Java. My goal is to integrate the big C application into my current java application.
Can any one tell me I should use JNI or CORBA? Which one is better in this case?
Thanks in advance!
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JNI (Java Native Interface) and CORBA (Common Object Request Broker Architecture) don't actually address the same domain. JNI helps you hook C-based libraries into one or more Java classes. CORBA helps you write distributed applications that can communicate among heterogeneous platforms.
JNI is the only technology that directly addresses the requirements you stated.
 
Kimberly Shu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.
However, issn't it true that CORBA can do pretty much what JNI can do?
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it is true that you can build CORBA wrappers to do pretty much anything you can do with CORBA. However, there are a few things to keep in mind: In CORBA you'll have to build a lot of wrapper objects that you will use to hold the information transferred across the network. Basically you're looking at one of these for each datastructure in your program. You'll also need a C++ CORBA ORB -- there are several open-source ones, but you'll probably still want to use a commercial one for the stability. However, at least in CORBA you won't crash the JVM if the C program crashes...
Kyle
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep, I can see the plausibility argument for CORBA, and how clever it would be to apply it in this case, if only to avoid the risks Kyle mentions.
My general rule in such cases is always choose tools and techniques based on their primary intent. Cleverness is something best demonstrated in small matters, to paraphrase William Strunk, and gets you in trouble with people maintaining your code who will immediately think they are looking at a distributed whatsis.
Along these lines, there are plenty of other and stranger alternatives that would add benefit at the cost of some clarity. You can't measure clarity in a benchmark, I know, but you sure can in a maintenance project.
 
Kimberly Shu
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for Michael and Kyle's advice. They are very helpful.
I think I'll go for JNI. Actually I need to run an artificial intelligence training program (SOM_PAK) in Java. It's a very computionally intense application. I may have speed problem.
Since I'm new to both JNI and CORBA. I have to try out and see.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!