Just I want to execute the Jar file from C sharp code and get return values from jar. Is it possible?
If so give me the sample code.
I tried following thing,
string path = "C:\\Documents and Settings\\Desktop";
Process process = new Process();
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
process.StartInfo.CreateNoWindow = false;
process.StartInfo.FileName = "C:\\Program Files\\Java\\jre6\\bin\\java.exe";
process.StartInfo.Arguments = "-jar \"" + path + "\\simple.jar\"";
process.Start();
String s = process.StandardOutput.ReadToEnd();
here simple.jar has main method which will take the arguements and prints the passed arguemnets in console, otherwise it prints no arguements in console. I tried above code in this line(String s = process.StandardOutput.ReadToEnd();) able to read the console values.
But I want to execute a method by passing values in jar and method will return me hashmap (collection) values(I don't know it is possible or not). Please give me suggestions on this.