wood burning stoves*
The moose likes Beginning Java and the fly likes A static native method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "A static native method" Watch "A static native method" New topic

A static native method

Jasper Vader
Ranch Hand

Joined: Jan 10, 2003
Posts: 284
in this code...
public class Mod{
public static void main(String argv[]){
public static native void amethod();
a native method is declared static. It compiles okay, but if amethod is called at runtime, a runtime error occurs. Is this because it is declared static?

giddee up
Rikard Qvarforth
Ranch Hand

Joined: Jul 10, 2001
Posts: 107
No its because you have the method native and the the body of the method residence outside the JMV, in a libary maby written in a non-java language.
like c++ basic. so you have to load the libary into the jmv this can be done in a static code example follows
static {
so i think the exception is thrown when the Jmv cant find the libary because you have not loaded it.
Jasper Vader
Ranch Hand

Joined: Jan 10, 2003
Posts: 284
Thanks Rikard
I agree. Here's the link: http://aspose.com/file-tools
subject: A static native method
Similar Threads
Never Thought About This!!!!!
Overriding a Method
native modifier
Why not Compilation error here!
native method