Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3395904
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T04:20:39+00:00 2026-05-18T04:20:39+00:00

I need to start external executable in such way that user can interact with

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T04:20:40+00:00Added an answer on May 18, 2026 at 4:20 am

    You need to get an output stream in order to write to the process:

    OutputStream out = proc.getOuptutStream();
    

    This output stream is piped into the standard input stream of the process, so you can just write to it (perhaps you want to wrap it in a PrintWriter first) and the data will be sent to the process’ stdin.

    Note that it might also be convenient to get the error stream (proc.getErrorStream) in order to read any error output that the process writes to its stderr.

    API reference:

    • http://download.oracle.com/javase/6/docs/api/java/lang/Process.html
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For RMI on server-side, do we need to start rmiregistry program, or just call
I need to start 1-3 external programs in my Java application that have paths
I need a way to tell ASP.NET Kill the current session and start over
I need to start an external process from my web application. This means using
I've inherited a Java web-services code-base (BEA/Oracle Weblogic) and need to start/launch an external
In the debug properties of my c# project I have selected Start External Program
Normally to attach a debuger to a running jvm you would need start the
I need to start messing with a vb.net(vs2008) project file and I'd like a
I need to start and stop SQL Server from the command line. I am
I need to start developing in FORTRAN, any recommendations on learning\developing FORTRAN coming from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.