IT Community - Software Programming, Web Development and Technical Support

How do I call the native API from Java?

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 ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > Java Programming

Register FAQ Members List Calendar Mark Forums Read
  #1  
Old 07-30-2007, 08:00 AM
oxygen oxygen is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 632
oxygen is on a distinguished road
Default How do I call the native API from Java?

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...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2  
Old 07-30-2007, 08:02 AM
kingmaker kingmaker is offline
D-Web Genius
 
Join Date: Jun 2007
Posts: 881
kingmaker is on a distinguished road
Send a message via MSN to kingmaker
Thumbs up Re: How do I call the native API from Java?

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.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3  
Old 08-06-2007, 08:43 AM
leoraja8 leoraja8 is offline
D-Web Sr.Programmer
 
Join Date: May 2007
Posts: 190
leoraja8 is on a distinguished road
Default Re: How do I call the native API from Java?

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.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

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


All times are GMT -7. The time now is 01:44 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.
Our Partners
One Way Moving Companies | Stamford Dentist | Euro Millions Lottery | Home Loans| Furniture

SEO by vBSEO 3.0.0