Re: [fpc-pascal] Access fpc libraries with Java ?

2014-03-31 Thread fredvs
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:

Re: [fpc-pascal] Access fpc libraries with Java ?

2014-03-31 Thread Alan Krause
Here is a somewhat dated version of JNI.pas http://pastebin.com/DR3px8GT for FPC which might help you out. Alan On Mon, Mar 31, 2014 at 6:44 AM, fredvs fi...@hotmail.com wrote: now the last obstacle : Callback procedures... Hum, i do not find why it is not working ;-( I follow jni c

Re: [fpc-pascal] Access fpc libraries with Java ?

2014-03-31 Thread leledumbo
Here is a somewhat dated version of JNI.pas for FPC which might help you out. So now we have 3 JNI.pas wrapper... I don't see any disclaimer, doc, changelog, whatsoever. Where do you get it? Also, if you don't mind, update the dirty {$ifdef mswindows}stdcall;{$else}cdecl;{$endif} with:

Re: [fpc-pascal] Access fpc libraries with Java ?

2014-03-31 Thread Alan Krause
I have absolutely *no* idea where I got it - only that it works as advertised. Alan -- Alan L. Krause jr.al...@shermanloan.com*Manager of Software Development*Voice: (760) 634-1700Sherman and Associates, Inc. http://www.shermanloan.com/Fax: (760) 634-1992 On Mon,

Re: [fpc-pascal] Access fpc libraries with Java ?

2014-03-31 Thread fredvs
Yep, i get it ;-) Explanations on Lazarus forum : = http://forum.lazarus.freepascal.org/index.php/topic,24063.msg144634.html#msg144634 No more obstacle now, Java is in the pocket. Cheers. - Many thanks ;-) -- View this message in context:

Re: [fpc-pascal] Access fpc libraries with Java ?

2014-03-29 Thread fredvs
Custom Drawn Android Module Wizard has JNI wrapper, but they develop each independently and I have no idea which one is better. Choose wisely. Yes, but sadly, both do not implement the JStringToString() function from the original Delphi jni.pas. OK, i will try to implement JStringToString()

Re: [fpc-pascal] Access fpc libraries with Java ?

2014-03-29 Thread fredvs
OK, i will try to implement JStringToString() function (or find the conversion-solution)... Done = function JStringtoString(PEnv: PJNIEnv; Obj: JObject; JavaStr: JString) : String; var ifcop : pjboolean; begin result := (PEnv^).GetStringUTFChars(PEnv, JavaStr, ifcop); end; He, he, he, ...

Re: [fpc-pascal] Access fpc libraries with Java ?

2014-03-28 Thread Sven Barth
On 28.03.2014 02:04, fredvs wrote: Your code is working PERFECTLY and trust me, even at StackOverflow.com, they do not know your trick, there are lot of questions for that without any working answer. Your GENIUS trick is to export name = Java_MyLib_MyProcedure. I do not know if that could be

Re: [fpc-pascal] Access fpc libraries with Java ?

2014-03-28 Thread leledumbo
PS: Hum, why did you use = env,jcls: pointer; as arguments, is it needed for Java ? I have try without and it works too... It's JNI requirement, I wonder it could work without as it may corrupt the stack. The first parameter is the JVM environment, the second is the Java object (or class

Re: [fpc-pascal] Access fpc libraries with Java ?

2014-03-28 Thread Helmut Weber
27, 2014 10:18 PM Subject: Re: [fpc-pascal] Access fpc libraries with Java ? Yep, yep, yep, ... tetra * mega thanks. Hum, i have very poor knowledge with Java. Of course i can do a Hello World and some other things. But now, because of some fpc libraries, i explore the import native library

Re: [fpc-pascal] Access fpc libraries with Java ?

2014-03-28 Thread Mattias Gaertner
On Fri, 28 Mar 2014 09:55:47 +0100 Helmut Weber h-g-we...@t-online.de wrote: Java is quite similar to C or C++. What kind of Java are you talking about? Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org

Re: [fpc-pascal] Access fpc libraries with Java ?

2014-03-28 Thread Helmut Weber
@lists.freepascal.org Sent: Friday, March 28, 2014 10:18 AM Subject: Re: [fpc-pascal] Access fpc libraries with Java ? On Fri, 28 Mar 2014 09:55:47 +0100 Helmut Weber h-g-we...@t-online.de wrote: Java is quite similar to C or C++. What kind of Java are you talking about? Mattias

Re: [fpc-pascal] Access fpc libraries with Java ?

2014-03-28 Thread fredvs
And then there are even specific tutorials if you look for JNI tutorial and maybe some language name and with the advent of Android this got even more, because this is the way how you interface native with Java code there... Hum, have you really test those tutorials ? You must be a very good

Re: [fpc-pascal] Access fpc libraries with Java ?

2014-03-28 Thread leledumbo
Hum, have you a idea how to deal with Pchar and Callback-Procedure ? Welcome to real JNI programming :) For this, you can no longer ignore the first 2 parameters. PChar can't be passed to Java AFAIK (it will violate Java safety rule). However, there's another way around: expect a jstring instead

Re: [fpc-pascal] Access fpc libraries with Java ?

2014-03-28 Thread fredvs
It's JNI requirement, I wonder it could work without as it may corrupt the stack. The first parameter is the JVM environment, the second is the Java object (or class in case of static method), the rest is actual parameters to the function. Yep, you are right, it was working only for function

Re: [fpc-pascal] Access fpc libraries with Java ?

2014-03-28 Thread fredvs
Welcome to real JNI programming :) Yep, i will study deeply JNI and the JNI Pascal wrapper. See you later. ;-) Thanks. - Many thanks ;-) -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Access-fpc-libraries-with-Java-tp5718791p5718810.html Sent from the

[fpc-pascal] Access fpc libraries with Java ?

2014-03-27 Thread fredvs
Hello. I try to access fpc libraries with Java. I can access those libraries with: = Python without problems, even callback functions... = fpc programs, of course... But with Java i get trouble... I try with JNA : https://github.com/twall/jna But without luck. Does somebody already had access

Re: [fpc-pascal] Access fpc libraries with Java ?

2014-03-27 Thread hinstance
JNI is the way to go http://en.wikipedia.org/wiki/Java_Native_Interface JNI is a part of Java, so no other libraries are required to use it 27.03.2014, 19:11, fredvs fi...@hotmail.com: Hello. I try to access fpc libraries with Java. I can access those libraries with: = Python without

Re: [fpc-pascal] Access fpc libraries with Java ?

2014-03-27 Thread leledumbo
fpcside: // fpclib.pas library fpclib; procedure test(env,jcls: pointer; i: longint); cdecl; begin writeln(i); end; exports test name 'Java_TestFPC_test'; end. java side: // TestFPC.java public class TestFPC { public static native void test(int i); public static void main(String[]

Re: [fpc-pascal] Access fpc libraries with Java ?

2014-03-27 Thread fredvs
Yep, yep, yep, ... tetra * mega thanks. Hum, i have very poor knowledge with Java. Of course i can do a Hello World and some other things. But now, because of some fpc libraries, i explore the import native library part of java. And, what surprise me, in Java forum, was that lot of Java

Re: [fpc-pascal] Access fpc libraries with Java ?

2014-03-27 Thread fredvs
Yep Leledumbo, this time you kill me. Your code is working PERFECTLY and trust me, even at StackOverflow.com, they do not know your trick, there are lot of questions for that without any working answer. Your GENIUS trick is to export name = Java_MyLib_MyProcedure. I do not know if that could be