I am writing code in java which calling delphi dll. to invoke the delphi dll I am usig JNA and its work great. My problem is when events are being called in the delphi and I need to invoke java code. is this possible in JNA?
-
You might find the following link to be of some use : stackoverflow.com/questions/16501194/…Peter– Peter2013-05-26 08:12:33 +00:00Commented May 26, 2013 at 8:12
-
I have alraedy saw this post, this post talk about invoke delphi functions from java, and I need to invoke java code from delphi, and I Know there is the JNI, but I hope that JNA can do that tooEran Friedland– Eran Friedland2013-05-26 11:41:39 +00:00Commented May 26, 2013 at 11:41
1 Answer
As discussed on the related thread (loading a delphi dll in java using jna), the flow is:
- create dll in delphi
- create a delphi or c++ app that can load the dll and successfully call the funcs in it --- do not proceed until this is done!
- now load dll from JNA
The interesting part for your project is that you want the delphi code to invoke java code.
I can think of only two ways to achieve the delphi --> java flow:
Implement a callback on the java side, so the delphi code can pump java code when needed (How to use JNA callback)
Have the delphi dll start a thread (that is bad, better: in java start a thread which loads a delphi dll func that runs) and use a different kind of IPC for the delphi code to pump java code (via a socket, shared memory, or other technique)