File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how Java does interprocess with C?

 
Ravindranath Chowdary
Ranch Hand
Posts: 71
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this topic is too advanced for the beginners forum, so I'm promoting it to the intermediate forum.
 
Yamida Frank
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic