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

  • SEARCH
  • Home
  • 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
  • 1 View
  • 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

I need to start a program every time the user logs in, but I
I need to start 1-3 external programs in my Java application that have paths
I'm developing a C# application and I need to start an external console program
I need to start up a jetty with an external (possibly remote) .war file
I need to start NSTimer by 0:0:0 that I am doing and I have
I need to start a project that will be json-API-centric, which means that most
I want to (need to) start a sub-process from a perl script that checks
I need to launch an external process that is to be controlled via messages
My goal is to create an executable that will start a shadow copied application.
I need to create an method invoker that any thread (Thread B for example

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.