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:
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
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:
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,
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:
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()
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, ...
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
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
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
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
@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
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
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
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
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
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
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
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[]
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
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
21 matches
Mail list logo