aspose file tools*
The moose likes Java in General and the fly likes how  Java does interprocess with C? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "how  Java does interprocess with C?" Watch "how  Java does interprocess with C?" New topic
Author

how Java does interprocess with C?

Ravindranath Chowdary
Ranch Hand

Joined: Nov 08, 2006
Posts: 71
Hi Friends,
I read as when ever native method is called the C code corresponding to that method is called. I have two doubts on this...
1. How that C/C++ -language code is executed when java program runs with native methods?
2. How the output from the C code is getback to the java program?

Can you please clarify on this.

Thanks,
Ravindra.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

I think this topic is too advanced for the beginners forum, so I'm promoting it to the intermediate forum.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Yamida Frank
Greenhorn

Joined: Oct 07, 2007
Posts: 4
Originally posted by Ravindranath Chowdary:
Hi Friends,
I read as when ever native method is called the C code corresponding to that method is called. I have two doubts on this...
1. How that C/C++ -language code is executed when java program runs with native methods?
2. How the output from the C code is getback to the java program?

Can you please clarify on this.

Thanks,
Ravindra.


1.The problem is solved using JNI, Java native interface, c/c++ code is invoked by the system, it has nothing to do with java, since it is not excuted in JVM, while java code does.JNI just act like a bridge, it connects native code and java code, when java program runs with native methods, the native methods is run by the system, while the result is passed to java code by JNI.
It's just my opinion on this problem, if wrong, i hope anyone to give me a correction.
2.This is done by JNI, simplely by value passing, of course there is a map between java type and the types of other programming languages.But i have no idea on how JNI coordinate this process, maybe you can read Java Native Interface Specification. you can see http://java.sun.com/j2se/1.3/docs/guide/jni/spec/jniTOC.doc.html
or ibm's overview of jni through http://publib.boulder.ibm.com/infocenter/javasdk/v5r0/index.jsp?topic=/com.ibm.java.doc.diagnostics.50/diag/understanding/jni_spec_impl.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how Java does interprocess with C?