Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A static native method

 
Jasper Vader
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Rikard Qvarforth
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 {
System.loadLibary("LibaryWrittenInC++");
}
so i think the exception is thrown when the Jmv cant find the libary because you have not loaded it.
 
Jasper Vader
Ranch Hand
Posts: 284
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rikard
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic