I want to run a java program from powershell and get the results printed on the console.
I followed the instructions on this: Capturing standard errors and startup errors
But for me it did not work as I expect. What am I doing wrong?
This is the script:
$psi = New-object System.Diagnostics.ProcessStartInfo $psi.CreateNoWindow = $true $psi.UseShellExecute = $false $psi.RedirectStandardOutput = $true $psi.RedirectStandardError = $true $psi.FileName = 'java.exe' $psi.Arguments = @("-jar","tools\compiler.jar","--compilation_level", "ADVANCED_OPTIMIZATIONS", "--js", $BuildFile, "--js_output_file", $BuildMinFile) $process = New-Object System.Diagnostics.Process $process.StartInfo = $psi $process.Start() | Out-Null $process.WaitForExit() $output = $process.StandardOutput.ReadToEnd() $output
The $ output variable is always empty (and, of course, nothing is printed on the console).
java windows powershell
devundef Jul 17 2018-12-21T00: 00Z
source share