Hi,
I have a software which contains a jar file. To use it I need to type "java -cp IPC.jar ipc.IPC -c CCl4 -t > CCl4.txt" in the command line. I want to invoke this in C#.
I used this following code but it is doing nothing, no errors.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
namespace WindowsFormsApplication7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
String strJarFilePath = "D:\\Downloads\\IPC_Program\\IPC.jar";
Process proc = new Process();
try
{
proc.StartInfo.FileName = "java";
proc.StartInfo.Arguments = "-cp " + strJarFilePath + "ipc.IPC -c C400Cl400 -t > ccl4.rtf";
proc.StartInfo.CreateNoWindow = false;
proc.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
proc.StartInfo.UseShellExecute = false;
DirectoryInfo currentDir = new DirectoryInfo(Environment.CurrentDirectory);
proc.StartInfo.WorkingDirectory = currentDir.FullName;
proc.Start();
proc.WaitForExit(5000);
}
catch (Exception ex)
{
if (!proc.Start())
throw new Exception("Failed to start Pull process");
}
}
}
}
At the end it should write the result (displayed in the command line) in a text file.
thanks,
Srikanth