1

The following Java code executes a command prompt with OpenSSL started and respective arguments.

When I type in the exact code in the command prompt it works and creates the output file in my home directory. However, through my java app it just launches the cmd quickly and shuts down without creating the output file in my home directory.

Runtime rt = Runtime.getRuntime();      
try {
    rt.exec(new String[]{"cmd.exe","/c","start  openssl enc -aes-256-cbc -nosalt " +
        "-in temp2.txt -out temp2.txt.enc -p -pass pass:QAAyADgAOAA9AEYAMAA6AEgANwBDAEIA"});

} catch (IOException e) {
    e.printStackTrace();
}

Any ideas? Thanks in advance!

jww
  • 97,681
  • 90
  • 411
  • 885
user2402616
  • 1,434
  • 4
  • 22
  • 38
  • 1
    Did you try using full path names for temp2.txt and temp2.txt.enc? – gtrig May 23 '13 at 00:51
  • 1
    Related, see [ProcessBuilder and running OpenSSL command which contains spaces](http://stackoverflow.com/q/30433917). – jww Jun 01 '15 at 01:58

0 Answers0