Should I use JNI or Runtime.exec??
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Eoin_Wren
Posted On:   Thursday, August 2, 2001 10:07 AM

HI,

I have a bunch of c libraries which I would like to use from my java program. The c libraries have been compiled into a program which can be executed from the command line. What is the best way to use this code, write some c wrapper code and call this from Java using JNI, or call the comand line executable using the java runtime api.....any pros or cons for each??.....

thanks

Re: Should I use JNI or Runtime.exec??

Posted By:   Dermot_Hennessy  
Posted On:   Friday, August 3, 2001 01:16 AM

Depends on what way you wish to interact with the C process. Use of Runtime.exec() is fine for kicking off a C executable, but it's pretty much 'fire and forget', as the Java program does not gain any extra communication with the C process.

On the other hand, JNI offers the capability of calling API methods on a C library from Java, so the passing of information from Java to C and vice versa is much finer grained. Of course, JNI requires more work, so you need to do a requirements analysis before deciding between the two.

Dermot

About | Sitemap | Contact