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 824981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:10:53+00:00 2026-05-15T03:10:53+00:00

Process p; String line; String path; String[] params = new String [3]; params[0] =

  • 0
Process p;
String line;
String path;
String[] params = new String [3];

params[0] = "D:\\prog.exe";
params[1] = picA+".jpg";
params[2] = picB+".jpg";

try
{
    p = Runtime.getRuntime().exec(params);

    BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));

    while ((line = input.readLine()) != null)
        System.out.println(line);

    input.close();
}
catch (IOException e)
{
    System.out.println(" procccess not read"+e);
}

I don’t get any error, just nothing. In cmd.exe prog.exe is working fine.

What to improve in order to make this code working?

  • 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-15T03:10:53+00:00Added an answer on May 15, 2026 at 3:10 am

    Perhaps you should use waitFor() to obtain the result code. This means that the dump of the standard output must be done in another thread:

    String path;
    String[] params = new String [3];
    
                        params[0] = "D:\\prog.exe";
            params[1] = picA+".jpg";
            params[2] = picB+".jpg";
    
            try {
                final Process p = Runtime.getRuntime().exec(params);
                Thread thread = new Thread() {
                    public void run() {
                        String line;
                        BufferedReader input =
                           new BufferedReader
                             (new InputStreamReader(p.getInputStream()));
    
                         while ((line = input.readLine()) != null)
                             System.out.println(line);
    
    
                         input.close();
                   } catch (IOException e) {System.out.println(" procccess not read"+e);}
                };
                thread.start();
                int result = p.waitFor();
                thread.join();
                if (result != 0) {
                    System.out.println("Process failed with status: " + result);
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public string Process<T>(string name, string address) { var dataObj= new Data<T>(); List<T> currentList= dataObj.GetAll(name);
The following code causes a NullReferenceException tStartParameter = String.Format(tStartParameter, tTo, tSubject) tProcess = Process.Start(New
Long story short... This doesnt work: Process p = new Process(); p.StartInfo.FileName = @External\PsExec.exe;
referring to my previous question at Unable to perform any action before Process.Runtime.exec statement
If I execute set PATH=%PATH%;C:\\Something\\bin from the command line ( cmd.exe ) and then
I use this code to process a date string coming in from a json
Lets write simple console application (debug mode): static void Main(string[] args) { Process p
i would like to process an undefinitely long string in C++ by chunks of
Given a very large string. I would like to process parts of the string
I'm trying to pass a string argument to a target function in a process.

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.