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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:17:12+00:00 2026-05-16T01:17:12+00:00

I’m writing (under linux or windows+cygwin) a java program that needs to run a

  • 0

I’m writing (under linux or windows+cygwin) a java program that needs to run a command (process P1) and read its stdout (which is mostly binary data useful to my program). This is easy to do, and already done.

The problem is that P1 also prints some status informations on stderr, and I would like to spawn a terminal (like xterm) to show it in a user-readable way.
Is there any easy method to do so?

I considered the option of just feeding some JTextArea with the output of stderr, but this program makes use of special control characters (in particular erase last line). Unfortunately, I couldn’t find any “Terminal (J)Component” freely available.

So the easiest way would be to be able to open an xterm (P2) that shows everything that comes to its stdin in its window, and start a java thread doing in loop err.read(P1) -> in.write(P2) to transfert everything from stderr(P1) to stdin(P2).
Another option would be to be able to launch something like “xterm -e P1_command” and still be able to capture P1 stdout…

Thank you very much for your help!

PS : I would like to remain as much portable as possible, so I’m not sure going into /dev/pts is a good idea

  • 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-16T01:17:13+00:00Added an answer on May 16, 2026 at 1:17 am

    Without completely understanding your problem, the easiest solution I can come up with is this (bash will replace $$ with the current process ID making it semi-unique). I also have no idea if this works in cygwin.

    mkfifo /tmp/myoutput.$$
    trap "rm /tmp/myoutput.$$" EXIT
    
    xterm -e cat /tmp/myoutput.$$ &
    
    runProgram 2>/tmp/myoutput.$$
    

    This will dump stderr to a fifo, which is read by cat in your xterm.

    Note that the cat will exit whenever you close the fifo, so if you’re spawning multiple instances of your process, then you’ll need some other control mechanism, and then there are probably other ways to solve it which are simpler. Such as running the entire thing in an xterm to begin with (including your java program), but I guess that’s not possible for some reason or you would’ve tried it already.

    EDIT:
    I suppose the most common way is to dump information to a log file, and tail it, like so:

    touch /tmp/myprogram.log
    xterm -e tail -f /tmp/myprogram.log &
    runProgram 2>/tmp/myprogram.log
    

    This should always work, but you might lose log messages if tail starts up too slow (look for flags in tail to echo the entire file before tailing). Combine it with a trap (and ‘unique’ filename) to remove the file and you don’t need to worry about clean up.

    What’s the reason for not running the entire app in an xterm?

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I would like to run a str_replace or preg_replace which looks for certain words
I need a function that will clean a strings' special characters. I do NOT

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.