Reputation: 87
I am currently writing a ruby plugin for a 3d drawing application(written in c ++, ruby is it's scripting language). What I want to do is communicate between that and another application written in java, both programs are running on the same computer. The ruby version that is integrated into the 3d drawing application is rather cut down and pretty basic and from what I understand has fairly limited or non existent socket libraries.
Any ideas on how to exchange information between the two applications would be greatly appreciated.
The amount of information that will be exchanged will be fairly small.
Upvotes: 2
Views: 457
Reputation: 12820
Your question may be answered in many, many ways. There is so many possible solutions...
One of the easiest, and yet pretty efficient method which comes to my mind, is to use standard input and standard output redirection to communicate between programs (written in any language).
Your Java program needs to execute a Ruby program, redirecting the input/output streams. I do not know the function which would be used in Java for this task, but in Ruby the method is IO.popen(command,mode)
.
Your Ruby program, called this way, just reads from STDIN
and writes to STDOUT
(plain methods gets
and puts
may be used).
You haven't said on what system you are programming, so I am not sure whether your platform is able to handle such redirection, or names pipes (which would be the second easy solution).
Upvotes: 2
Reputation: 1732
If not high Performance required ,you can use file on the disk of the computer to change the informations between two applications。 for example,if you want to transfer EVENT1 from Ruby app to Java app: Ruby app write a flag file called event1.flag on disk dir , while the Java app start a Thead keep searching the dir for .flag file.
Upvotes: 0