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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:10:43+00:00 2026-05-31T16:10:43+00:00

I have one application that prints messages from Test.exe in console .My java program

  • 0

I have one application that prints messages from Test.exe in console .My java program creates one process by executing this Test.exe.
This application prints messages by reading from input-stream of that process.

The problem, that I am facing is,
I have two scenarios:
1) When I double click test.exe, messages(“Printing : %d”) are printing for every second.

2)But when I run my java application,whole messages are printing at last(not for every second) before terminating Test.exe.
If .exe has a very huge messages to print,then it will print those messages(I think whenever buffer becomes full)and flushing will be done.


But how can I print messages same as 1st case.

Help from anyone would be appreciated. 🙂

Here is the code for this Test.exe.

#include <stdio.h>
#include <windows.h>
void main(void)
 {
  int i=0;

  while (1)
     {  
    Sleep(500);
    printf("\nPrinting : %d",i);
    i++;
       if (i==10)
      //if(i==100)
        {
        return 0;
        }
     }
}

And my Java application is below:

public class MainClass {
public static void main(String[] args) {

    String str = "G:\\Charan\\Test\\Debug\\Test.exe";
    try {
        Process testProcess = Runtime.getRuntime().exec(str);

        InputStream inputStream = new BufferedInputStream(
                testProcess.getInputStream());
        int read = 0;
        byte[] bytes = new byte[1000];
        String text;
        while (read >= 0) {
            if (inputStream.available() > 0 ) {
                read = inputStream.read(bytes);
                if (read > 0) {
                    text = new String(bytes, 0, read);
                    System.out.println(text);
                }
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
}

Is it possible in reverse order.If I input some text from console,Java should read and pass that String to .exe(or testProcess).How .exe scan something from Java program.

Could anyone help me..

  • 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-31T16:10:45+00:00Added an answer on May 31, 2026 at 4:10 pm

    Seems to have something to do with not flushing. I guess it’s on both sides – The C library you use seems to only automatically flush output when writing to a terminal. Flush manually after calling printf.

    On the Java side, try reading from a non-buffered stream.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have one web application (sharepoint) that collects information from disparate sources. We would
I have one grails application.In that I have one model class named Book. From
I have created one application in flex that is accessing the Java webservice using
We have an application that has one or more text console windows that all
I have a C++ application and a Java application that need to log messages
The problem: we have one application that has a portion which is used by
We are having problem with the server migration. We have one application that are
I have one form in a PHP (5.2.9-1) application that causes IIS (Microsoft-IIS/6.0) to
We have an application that generates simulated data for one of our services for
We have an application that performs comparisons on data objects to determine if one

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.