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

Integration Design Best Practice

Over the past few years of working on multiple critical systems solution design initiatives, there is one important thing I have learnt.  &q...