Could not open jarfile

I have a C # program that provides access to a java program using tcp. In my C # program, I run a java program on 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 great, I have not had a problem so far. I installed my program on a colleagueโ€™s computer. Now I get the error message: Could not access the jar file.

So, I tried the command line "java -jar javaApp.jar" and javaApp starts right away.

I tried to run the program as an administrator, the same error. (Windows Vista)

At the moment, I have no idea what the problem may be.

+1
java c #
source share
3 answers

I assume the jar file path contains spaces. You need to quote it. For instance:

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

2 things -

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

  • Does your program download any additional banks? perhaps they exist on the computer of your colleagues, but not on the one on which it will not work.

(although John Skeet's answer looks more likely)

0
source share

To learn more about what's happening, change your arguments to:

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

This way you can see what it is trying to download, and see if Jon Skeet is working properly.

0
source share

All Articles