Start exteranal executable from Java code with streams redirection
I need to start external executable in such way that user can interact with program that was just started.
For example in OpenSuse Linux there is a package manager - Zypper. You can start zypper in command mode and give commands like install, update, remove, etc. to it.
I would like to run it from Java code in a way user could interact with it: input commands and see output and errors of the program he started.

Here is a Java code I tried to use:

    public static void main(String[] args) throws IOException, InterruptedException {
    		Process proc = java.lang.Runtime.getRuntime().exec("zypper shell");
    		
    		InputStream stderr = proc.getInputStream();
            InputStreamReader isr = new InputStreamReader(stderr);
            BufferedReader br = new BufferedReader(isr);
            String line = null;
            char ch;
    
            	while ( (ch = (char)br.read()) != -1)
            		System.out.print(ch);
    
            int exitVal = proc.waitFor();
            System.out.println("Process exitValue: " + exitVal);
    
    	}
But unfortunately I can only see it's output:
   zypper>
but no matter what I write, my input doesn't affect program that was started.
How can I do what want to?
Thank in advance.
Start exteranal executable from Java code with streams redirection
===

I need to start external executable in such way that user can interact with program that was just started.
For example in OpenSuse Linux there is a package manager - Zypper. You can start zypper in command mode and give commands like install, update, remove, etc. to it.
I would like to run it from Java code in a way user could interact with it: input commands and see output and errors of the program he started.

Here is a Java code I tried to use:

    public static void main(String[] args) throws IOException, InterruptedException {
    		Process proc = java.lang.Runtime.getRuntime().exec("zypper shell");
    		
    		InputStream stderr = proc.getInputStream();
            InputStreamReader isr = new InputStreamReader(stderr);
            BufferedReader br = new BufferedReader(isr);
            String line = null;
            char ch;
    
            	while ( (ch = (char)br.read()) != -1)
            		System.out.print(ch);
    
            int exitVal = proc.waitFor();
            System.out.println("Process exitValue: " + exitVal);
    
    	}
But unfortunately I can only see it's output:
   zypper>
but no matter what I write, my input doesn't affect program that was started.
How can I do what want to?
Thank in advance.