开发者

Unable to access jar file

开发者 https://www.devze.com 2022-12-09 07:52 出处:网络
I have a c# program that access a java program by tcp. In my C# program I\'m starting the java program by this line of code:

I have a c# program that access a java program by tcp. In my C# program I'm starting the java program by this line of code:

var process = new Process
{
  StartInfo =
  {
      UseShellExecute = false,
      CreateNoWindow = false,
      FileName = "cmd.exe",
      Arguments = (@"/c java -ms16m -mx512m -jar pathToJavaApp/javaApp.jar 3562")
  }
};

This works fine I had no problems until now. I've installed my program on a colleague's computer. Now I'm getting the error: Unable to access the jar file.

So I tried in command line "java -jar javaApp.jar" and the javaApp starts immediately.

I tried starting the program as adm开发者_如何学Goinistrator, same error. (windows vista)

For the moment I have no idea what the problem could be.


My guess is that the path to the jar file contains spaces. You'll need to quote it. For example:

Arguments = "/c java -ms16m -mx512m -jar \"" + pathToJavaApp 
    + "\"/javaApp.jar 3562"


2 things-

  • it's -Xmx, and -Xms, not -ms, -mx.

  • Does your program load any additional jars? maybe they exist on your colleagues computer but not on the one it wouldn't run on.

(although Jon Skeet's answer looks more likely)


In order to see more about what is going on change your arguments to:

  Arguments = (@"/c java -verbose -ms16m -mx512m -jar pathToJavaApp/javaApp.jar 3562")

That way you can see what it is trying to load and see if Jon Skeet is correct.

0

精彩评论

暂无评论...
验证码 换一张
取 消