Error: Unable To Access Jar File


  • I am attempting to copy a zip file to a jar file in a C# method like this:

        ProcessStartInfo start = new ProcessStartInfo();
        start.FileName = "java.exe";
        start.WorkingDirectory = @"C:\mydir\";
        start.Arguments = @" -jar example.jar";
        Process java = new Process();
        java.StartInfo = start;
        var stdOut = java.StandardOutput.ReadToEnd();

    The problem is that I am receiving this error:
    Error: Unable to access jarfile example.jar

    I've confirmed that both example.jar and exist in the Working Directory and have also written a batch file that I can run and create a .jar file that is almost identical:

    jar -cf example.jar

    I was able to run this without issue with this code:

    const string batchFile = @"C:\mydir\batJar.bat";

    My environment variables are also set up properly.


    Wednesday, March 20, 2013 9:20 PM


All replies

  • Why do you think your question is related to C#? Does your batches work when invoked directly? Do you receive an error - what ever this is - or do you receive an Exception? If so, where does the exception occur?
    Wednesday, March 20, 2013 9:59 PM
  • Hi,

    please check what you are doing!

    java -jar jarfile arguments
    => this starts an existing jar file and arguments are arguments to the command.

    jar -cf newfile content
    => this creates a new jar file and simply puts content inside.

    But what do you want to get? You have an zip file and you want a jar file? jar files are a ZIP file. Just rename them. (

    With kind regards,


    Thursday, March 21, 2013 1:18 PM