0

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.

7
  • Did you at least Google delphi jni? Commented Nov 25, 2013 at 17:47
  • How are the two pieces of code connected? Two processes, or one? Commented 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. Commented 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. :-) Commented 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 reading Commented Nov 25, 2013 at 18:30

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

6 Comments

Without using sockets, is it possible to access through any interface oriented functionalities.
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.
@sathiya, in other words, you cannot do this without modifying your current Java program.
Thanks a lot guys.I feel that i can use sockets to get the data.
Or named pipes. Or windows messages.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.