Visual J# Developer Center > Visual J# Forums > Visual J# General > How to run .jar file from ASP.NET application? Error?
Ask a questionAsk a question
 

QuestionHow to run .jar file from ASP.NET application? Error?

  • Thursday, September 17, 2009 5:51 AMSairam2525 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi

    Could anyone let me know what is wrong with the below code.
    It is not displaying any message.

    I have a button click event which runs .jar file from C#.NET application.
    //Button Click Event for running .jar file
    protected void btnRunJarApplication_Click(object sender, EventArgs e)
    {
    String strJarFilePath = "\\testHelloWorldNew.jar";

    Process proc = new Process();
    try
    {
    proc.StartInfo.FileName = "java";
    proc.StartInfo.Arguments = "-jar " + strJarFilePath;
    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();
    //give Processor 5sec to close
    proc.WaitForExit(5000);
    }
    catch (Exception ex)
    {
    if (!proc.Start())
    throw new Exception("Failed to start Pull process");

    }
    }


    I have the following questions:
    (1). testHelloWorldNew.jar file is displaying the "Welcome to HelloWorld!" from Command Prompt. How can i either capture this message or the status of the execution of .jar file??
    (2).How to make sure this process is executing correctly and closing?

    Can anybody throw some light on this?

    Thanks.

All Replies

  • Sunday, September 27, 2009 9:40 PMkaymaf Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Try ASP.NET forum for your question may for better responses. This J# forum is dead.
    http://forums.asp.net/

    kaymaf
    I hope this helps, if that is what you want, just mark it as answer so that we can move on