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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:55:03+00:00 2026-06-01T08:55:03+00:00

From Java, I run a C++ app which logs its progress as it proceeds,

  • 0

From Java, I run a C++ app which logs its progress as it proceeds, and want to monitor that there is some progress continually, so (in Java) I monitor process.getInputStream() and process.getErrorStream(). When I run the C++ app from the command line, the log appears one line at a time as it progresses (about 1 line very 1-2 seconds). From the Java monitor, I’m not getting the data in realtime, and am not sure who is buffering it.

I can look at the C++ code (though it’s rather complex) and try to put flush() calls as necessary, but the data appears in realtime when I run it from cmd.exe, so before I do that, I’d like to check out if there is something else along the way that I have to do. Is there something in Java I have to do to get the data in realtime, to make sure the input stream is not buffered?

I’m running in Windows XP and above.

I tried

            for (;;) {
                int c = is.read();
                if (c < 0) {
                    break;
                }
                System.out.print(c);
                System.out.flush();
            }
            if (true) {
                return;
            }

and also tried

            InputStreamReader isr = new InputStreamReader(is);
            BufferedReader br = new BufferedReader(isr);
            String line = null;
            while ((line = br.readLine()) != null) {
                synchronized (lastActivityTime) {
                    lastActivityTime = java.util.Calendar.getInstance().getTimeInMillis();
                }
                if (pw != null) {
                    pw.println(type + line);
                    pw.flush();
                }
            }
  • 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-06-01T08:55:04+00:00Added an answer on June 1, 2026 at 8:55 am

    It is the source process that is doing the buffering, in the stdio library. There is nothing you can do about that at the Java end. You have to put fflush() calls into the C++ code, or put up with it and wait. The data appears in real time when you run from cmd.exe because stdio behaves differently when attached to what it thinks is a real terminal.

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

Sidebar

Related Questions

I want to run Protovis javascript from Java and get the evaluated SVG code.
How do you run a java program that requires input from a file in
Is it possible to run JUnit tests from inside my Java application? Are there
Let's say I have a Java app which uses a (static) int constant from
I have a Java class which is located in src/java that references classes from
I'm running a server app (written in Java) under GNU/Linux which takes input (from
I need to invoke a mapreduce job from java application. I use ToolRunner.run(new Validation(),
How would you run the Selenium process (thread) from a Java process so I
I need to run an external application from within my Java code. I can
how can I save a java applet from a website so I can run

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.