I want to make a plugin for Eclipse. The thing is that I looked into the API, and examples, and I managed to make a button on main bar, with a specific icon, and when I click it, open up an InputDialog.
The hard part, is that I want to start an aplication from this button, but not with Runtime as it was a new process. I simply want to start a class inside plugin, which will log in to a server and get some output from it. I want it to be opened in a console, like launching a normal application, or a separate console.
The best example of this kind is a Tomcat plugin which starts Tomcat, and then outputs the console to the Eclipse console. I want to do that too. I’ve looked at the Tomcat source plugin, but I got stuck there too. They use their own launcher.
I am not sure what you mean by “I want to simply start a class”. I assume there is a command line tool that you want to execute and redirect its output to the console window.
To be able to do that without spawning a new process, you have to be able to control the output stream of the tool. If it cannot be controlled, then you have no choice but to start a new process to properly capture the tool’s output.
It is technically possible to call
System.setOutinstead, but it will redirect output from all threads to your console which is not what you want.Nevertheless you start by creating a console:
Then set the input and output streams of my tool and start processing in a different thread so the UI will not block.
If your tool does not support I/O redirection, you have no choice but to start it in another process with the
ProcessBuilderand use a number of threads to move data between console and process streams See:Process.getInputStream(),Process.getOutputStream()andProcess.getErrorStream().The following links have additional useful details: