This is a discussion on How do I call the native API from Java? within the Java Programming forums, part of the Software Development category; How do I call the native API from Java? I met a situation to call native API from Java..Not ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
|
#1
| |||
| |||
| How do I call the native API from Java? I met a situation to call native API from Java..Not able to implement..
__________________ The OXYGEN Delivers edgy, intelligent Technology to all... |
|
#2
| |||
| |||
| You can do this only in an application, not in an applet. You will need to write some intermediary code in C or another traditional language and call your C code from Java. |
|
#3
| |||
| |||
| public class HelloWorld { private static native void writeHelloWorldToStdout(); public static void main(String[] args) { writeHelloWorldToStdout(); } } Go ahead and compile the given class. Since our native method will be written in C, it makes no sense for it to contain code (hence, it is a declaration only; vaguely like an abstract method). The Java compiler simply accepts that if a method is declared native, the implementation of the method will be loaded into the VM at runtime. |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| difference between call by value and call by reference | amansundar | Java Programming | 2 | 09-18-2007 01:34 AM |
| How Do I Call C Code from Java? | kingmaker | Java Programming | 2 | 08-06-2007 08:31 AM |
| Function call and System call | vigneshgets | Operating Systems | 1 | 08-01-2007 06:18 AM |
| How Do I Call Java from C? | kingmaker | C and C++ Programming | 1 | 07-30-2007 07:58 AM |
| What means by Java Native Interface?Benifits of its | prasath | Java Programming | 1 | 07-19-2007 05:04 AM |
Our Partners |