[fpc-pascal] Access fpc libraries with Java ?

fredvs fiens at hotmail.com
Mon Mar 31 15:44:26 CEST 2014


>> now the last obstacle : Callback procedures... 

Hum, i do not find why it is not working ;-(

I follow jni c examples but with no luck.

Does somebody knows how to deal with callback procedures and Java ?

Here Library Pascal code :

procedure formonclick(PEnv: PJNIEnv; Obj: JObject; aproc: JString); cdecl;
begin
JMethod :=
(PEnv^^).GetStaticMethodID(PEnv,(PEnv^^).GetObjectClass(PEnv,Obj),(PEnv^^).GetStringUTFChars(PEnv,
aproc, nil),'()V')  ; 
end;

And here Java code :

public class fpg {	
	
public native void register();
public void callback() {
writeln("Ýep it works");
}
 public static native void buttononclick(int i, int j, String t);
 
  public static void main(String[] args) {
    System.loadLibrary("fpg");
     formonclick("callback");
    }    
} 

fpc Library and java app compiles but when running the java app i get that
error :

>>Exception in thread "main" java.lang.NoSuchMethodError:  callback1
>> at fpg.formonclick(Native Method)  at fpg.main(fpg.java:34) 

What is wrong ? => I do not understand because callback is declared in main
java thread..

Any help would be extremely appreciated.

Many thanks.
                   
Fred.



-----
Many thanks ;-)
--
View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Access-fpc-libraries-with-Java-tp5718791p5718829.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.



More information about the fpc-pascal mailing list