Tuesday, September 13, 2011

Executing Java .jar within .NET

using System.Diagnostics;

Process process = new Process();

//Path wherein Java is installed in your machine
process.StartInfo.FileName = "java.exe";
//.jar file to be executed
process.StartInfo.Arguments = @"-jar Sample.jar";

process.StartInfo.UseShellExecute = false;

process.StartInfo.RedirectStandardOutput = true;

process.StartInfo.RedirectStandardError = true;


//Get the output from stream

//in case of no error ExitCode will be zero
//In case of error , get error description
string error = process.StandardError.ReadToEnd();



1 comment:

Jonathan Elano said...

Thank you so much for the post. It is a great help for us! jvmhost

Tranformation in Manufacturing

 Do you want to know how CPG industry  is undergoing transformation using IoT technology, read the blogs on how AWS partners are using AWS t...