BufferredWriter.write() to process works in Intellij, but not in jar

46 Views Asked by At

I'm trying to run the program trezorctl to sign a Qtum transaction built in Java alongside a Trezor device, by creating a process through ProcessBuilder that runs the command trezorctl sign-tx <name_of_file>.json. After running it, you will often need to input your PIN before confirming the transaction.

I am inputting the PIN to the process using a BufferedWriter(OutputStreamWriter(proc.getOutputStream())) by calling write(pin), then newLine(), then flush(). This works on Linux and on Mac when running the program through Intellij, but when I build the jar file and run that, it doesn't. trezorctl doesn't receive the input and my program hangs at the next stdInput.next(). On Windows this behaviour also occurs on Intellij.

Why would it work in one case and not the other, even within the same OS? When I run the command line application manually on Windows, it works on cmd, but not on Git bash, exhibiting similar behaviour. I don't know if this matters, but trezorctl masks the input so you can't see the PIN, would that affect this? I've also tried running my program with sudo, so I don't think it's a permission issue.

0

There are 0 best solutions below