In Java Program, i have declared one global variable which starts from zero and used one timer to increase that global variable for every 5 seconds. And i started that application.My question is i need to access that particular procedure and also i need to access that variable through my Delphi application.I got some information about JNI file.Is it possible to use that to read the jar java application.
-
Did you at least Google delphi jni?Ken White– Ken White2013-11-25 17:47:15 +00:00Commented Nov 25, 2013 at 17:47
-
How are the two pieces of code connected? Two processes, or one?David Heffernan– David Heffernan2013-11-25 17:47:21 +00:00Commented Nov 25, 2013 at 17:47
-
No there is no connection between the two application.Just is it possible to read the data from OS level.Work 2 Enjoy - Enjoy 2 Work– Work 2 Enjoy - Enjoy 2 Work2013-11-25 18:11:50 +00:00Commented Nov 25, 2013 at 18:11
-
If you want two different processes, one in Java, and one in delphi to talk to each other, there are many easy ways, the one I know best is RemObjects. If you don't want to use two processes, then I suggest you have your java code write to a file, and have your Delphi code read the file. :-)Warren P– Warren P2013-11-25 18:12:12 +00:00Commented Nov 25, 2013 at 18:12
-
If there are two processes then you need IPC. Many options available. If you don't understand what IPC is then you need to do some background readingDavid Heffernan– David Heffernan2013-11-25 18:30:25 +00:00Commented Nov 25, 2013 at 18:30
|
Show 2 more comments
1 Answer
No, using JNI you can access native core, or you can from native code run Java. But here you need some IPC mechanism. I think that the best solution here is using sockets. Open listening socket in Java, acceps incoming connections and write current value of the global variable into socket's output stream. From Delphi connect this socket and read from socket's input.
6 Comments
Work 2 Enjoy - Enjoy 2 Work
Without using sockets, is it possible to access through any interface oriented functionalities.
Alexey Andreev
I think it is possible to use System V style IPC or named pipes or anything else. I guess there is implementation of these things in Java. But sockets are easier to use. If you want an RPC-like approach, see JAX-WS. But is is really very heavyweight library for such tiny task. Maybe there are some lightweight libraries providing RPC-like approach over plain sockets. And there is Java RMI, but I don't know whether Delphi has support for it.
Marcus Adams
@sathiya, in other words, you cannot do this without modifying your current Java program.
Work 2 Enjoy - Enjoy 2 Work
Thanks a lot guys.I feel that i can use sockets to get the data.
David Heffernan
Or named pipes. Or windows messages.
|