How to execute a Java program from C#?

Wondering if anyone knows a nice way to execute a Java command-line program from C# code at run-time ?

Is it the same as executing native .EXE files ?

Will it run synchronously or asynchronously (which means I may have to wait for the thread to finish to find out the results)

Specifically I would like to call a little utility (which happens to be written in Java) from a web-application on the server side to do some processing on a text file. I want to wait for it to finish because after the Java program is done processing the text file I want to grab the processed text, and use it within the C# application.


var processInfo = new ProcessStartInfo("java.exe", "-jar app.jar")
                      {
                          CreateNoWindow = true,
                          UseShellExecute = false
                      };
Process proc;

if ((proc = Process.Start(processInfo)) == null)
{
    throw new InvalidOperationException("??");
}

proc.WaitForExit();
int exitCode = proc.ExitCode;
proc.Close();

If you need finer control than launching an external program, then consider IKVM - http://www.ikvm.net/ - which provides a way to run Java programs inside a .NET world.