commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ioannis Latousakis <>
Subject [exec] Custom InputStream
Date Sun, 12 Feb 2012 00:27:47 GMT
I am trying to make a simple replicate of a terminal for a swing application.
I want to run a java class, and any of its errors or output to be displayed on a JTextPane.
The part where I am stuck is getting input from a JTextField , on a way similar to terminal(
type the command/ input hit enter ).
What I want is when pressing enter, my input is send to the process being executed.
I have tried overriding InputStream methods but it hasn't worked yet.

This is the class I want to control through my terminal .

public class NewClass {
    BufferedReader in ;
    public NewClass(){
        in = new BufferedReader(new InputStreamReader(;
    private void run(){
        while (true){
            System.out.println("Who are you ?");
            try {
                System.out.println("Hello "+in.readLine());
            } catch (IOException ex) {
                Logger.getLogger(NewClass.class.getName()).log(Level.SEVERE, null, ex);
    public static void main(String[] args) {
        new NewClass();

And this is how I set my custom output 

Executor ex = new DefaultExecutor();
ex.setStreamHandler(new PumpStreamHandler(out, outerr, in));

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message