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;

process.Start();

//Get the output from stream
Console.WriteLine(process.StandardOutput.ReadToEnd());

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

Console.WriteLine(error);

process.WaitForExit();

1 comment:

Jonathan Elano said...

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

Handle the error “OwnershipControlsNotFoundError” for buckets created prior to April 2023 when the bucket ownership was defaulted to “Object Writer”

Here you go published a  python code sample written for migrating S3 bucket ownership controls between AWS accounts. The code is written to ...