1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

calling jar file in c#

Discussion in 'C#' started by srikanth2321, Aug 28, 2010.

  1. srikanth2321

    srikanth2321 Guest


    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()
      private void Form1_Load(object sender, EventArgs e)
       String strJarFilePath = "D:\\Downloads\\IPC_Program\\IPC.jar";
       Process proc = new Process();
        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;
       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.



Share This Page