views:

55

answers:

2

i need to read some error message in java, i tried to do this in getErrorStream and then readLine, but i got exeption. i added a link to a picture of the error message i want to read http://yfrog.com/0986806495p

TNX

A: 

You can't

That error message is being displayed on the window manager of the operating system which is not readable.

Your attempt to read from the standard error are failing, probably because that application doesn't write to the standard error in first place.

OscarRyz
I disagree with the second part of your answer: Reading from stderr, if done correctly, will not hit an error just because there is nothing being written there. Instead, I suspect that even if he's doing `exec()`, he has an error in his program, as it isn't trivial to set up all the streams plumbing on an exec'd process.
Carl Smotricz
Of course, if done correctly. Done incorrectly may fail if there is nothing to read and he's forcing the read somehow. As for the currect state of the question we can't tell.
OscarRyz
+2  A: 

TrueCrypt isn't your Java program, and Java doesn't have a reasonably workable way to reach into another program's dialog to read the message.

getErrorStream() would work if TrueCrypt output a text to its standard error, but since it has a dialog to show the user it has little reason to do so.

It's possible that TrueCrypt returns a non-0 exit status if it fails, and you could catch that by using Runtime.getRuntime().exec("TrueCrypt.exe"), waiting for the resulting process to finish (using Process.waitFor()) and then checking the exit status you get there. However, you still need someone (or something) to hit the Ok button for you.

Carl Smotricz