Only 44 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

A static native method  RSS feed

 
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!