We have a C# application which starts a Process. The Process runs bash on a .bat file, and the .bat file starts a jar file.
I have figured out how to make the .bat file log its output into a logfile, through the code below:
Process process = new Process();
process.StartInfo.FileName = batFile;
process.StartInfo.Arguments = jarArguments;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.ErrorDialog = false;
process.Start();
while (!process.StandardOutput.EndOfStream)
{
log.Debug(process.StandardOutput.ReadLine());
}
process.WaitForExit();
My issue now is that I cannot get the output from the jar file. If I allow the bash process to create a new window (process.StartInfo.CreateNoWindow = false), I can see the output from the jar file. But if I don't create a new window, the output from the java jar does not get redirected into my logfile. My questions:
- At runtime, can a java jar have its output text location configured?
- Can the output from a java jar be re-directed to some file location, on a windows machine?