mardi 23 mai 2017

Java reflection with a java Process

I have a Process which is a Java application which was created from ProcessBuilder by running a command like java -Xms1024M -jar my.jar. This works fantastically, but the application I started does not use System.in for its input, so I can NOT use process.getOutputStream().

How could I get an instance of the running application from the process to use Java Reflection to send input? If I can't, how would I go about using Java Reflection to start the application from my runnable, then use Java reflection to get something I can work with.

To be more specific, I am trying to do this for BungeeCord.

  • The main class is net.md_5.bungee.Bootstrap.
  • Bootstrap calls the static method main in net.md_5.bungee.BungeeCordLauncher.
  • BungeeCordLauncher creates an instance of net.md_5.bungee and puts this instance in a static field called instance in net.md_5.bungee.api.ProxyServer AND there is a get method (Maybe this could be used for java reflection?)
  • Inside BungeeCord.class there is a method called getConsoleReader() and this is what I ultimately need to get and I need the current instance of it for this specific process.

Thank you for any help!





Aucun commentaire:

Enregistrer un commentaire