• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how Java does interprocess with C?

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic