0

I was wondering if there was any way to read straight off the CMD on windows without having inputs from a user using Java for text processing and returning new commands.

Specifically, I'm running a Minecraft server and want to create certain types of automatic responses (maybe with a bot) if certain typed events occur via the console. So if a player were to say "Lightning" lightning would strike nearby for example. But I'm struggling to find a way to read off the command line that the Minecraft server produces, so I can process the text and return a new input and automatically execute the new command.

I apologize if this is an obvious question!

  • I think this url can help you: https://www.quora.com/Can-we-open-a-command-prompt-using-Java-program – Mochida May 26 '20 at 17:22
  • 2
    Take a look at this question: https://stackoverflow.com/questions/14915319/get-output-of-terminal-command-using-java?lq=1 – Louis Dhont May 26 '20 at 17:22
  • If you start a `Process` in Java you can get the console output via https://docs.oracle.com/javase/8/docs/api/java/lang/Process.html#getInputStream-- You can read it and react on what you read. – Robert May 26 '20 at 17:23
  • 1
    Does this answer your question? [Get output of terminal command using Java](https://stackoverflow.com/questions/14915319/get-output-of-terminal-command-using-java) – aschipfl May 26 '20 at 18:01
  • @Robert Using the process class only creates an instance of the command line but I need access to the specific command line that the server.jar file produces when it's done executing. Maybe this will help I start the jar file with a bat file to enter simple start commands such as ram allotment. Would there be a way to execute this so it's all contained with the Process class? – user13576487 May 27 '20 at 18:24
  • @user13576487 Sorry but I don't understand what you are trying to do. Please update your question and describe exactly what process is starting what other process and where you want to modify something respectively what process is the Java program you are writing. Note: If you are trying to access other processes not started by you Java is the wrong language. – Robert May 27 '20 at 18:28

0 Answers0