-1

I Have two programs a.jar and b.jar, b.jar is a console application that i can't change, a.jar is a gui application that needs to send commands to b.jar that will then be interpreted there. a.jar also needs to receive the output of b.jar. I usually run b.jar in command prompt and type the commands for the program to run in command prompt and and it responds. I want to use a.jar to launch, listen to, and talk to (sent commands to) b.jar

joe pelletier
  • 390
  • 2
  • 12
  • Can I ask what b.jar is? – IByrd Feb 19 '15 at 22:29
  • b.jar represents a server console where game chat is displayed and admin commands can be executed, i want my program to listen to chat and respond by running commands in the console. i did not specify this in my question because i didn't think those details would make a difference. – joe pelletier Feb 20 '15 at 22:17
  • Well it sorta matters because you can't edit b.jar what you're going to have to do is some very technical stuff with editing or listening to packets and if it's a UDP port hijack the port every so often to send your own commands. Also this may violate terms of use for b.jar. – IByrd Feb 20 '15 at 22:19
  • that is awesome how can i do that – joe pelletier Feb 20 '15 at 23:03
  • Uhm, hmm well if they are both Java then I would look up on how to decompile b.jar and look through their [obfiscated](http://stackoverflow.com/questions/551892/how-effective-is-obfuscation) code. Remember this could be illegal depending on what program b.jar is haha. But, from here you would find out how b.jar accepts and sends messages and on what port through the source. Then from there you would need your program to be a modified version of that b.jar BUT just to send a message or two and let the b.jar have the port back. This is reverse engineering I think it's technical term is. – IByrd Feb 20 '15 at 23:34
  • This is going to take a lot of work and time might I add. – IByrd Feb 20 '15 at 23:35
  • is there a way to pipe data to the input of b.jar? – joe pelletier Feb 21 '15 at 19:56

3 Answers3

0

Maybe you can use an auxiliary file that the a.jar write and b.jar only read. To do this, you can instantiate an thread in b.jar like a timer and verify if the file has changes.

pedrohreis
  • 1,030
  • 2
  • 14
  • 33
0

I am not sure if there is an easy way to do that without editing the b programs source and recompiling. What you're really talking about is gaining access or exposing b.jar a compiled already running program to a.jar. I would imagine you'd need to edit memory and basically break program b.

I think the only easier way to do this would be to make a sort of Server Client relationship between a.jar and b.jar using sockets and what have you. But, you stated that you can't edit b.jar program.

Then there is the dirty way which is using the robot class which sounds gross and time consuming.

IByrd
  • 177
  • 1
  • 13
0

a.jar launches b.jar and represents it as a process object a.jar can scan from b.jar's input stream using new Scanner(process.getInputStream()) and print to its output stream new PrintStream(process.getOutputStream());

joe pelletier
  • 390
  • 2
  • 12