0

Hi All,

I am using system function to invoke a jar file in MAC OS. But the jar file path has space in the folder name.

string arg1= "MyWindow";
	string jarFile = "java -jar /Users/User1/Desktop/Sample Java/Demo.jar ";
	jarFile += arg1;
	system(jarFile.c_str());

"/Sample Java" folder name has space in between. Because of which the jar is not coming up. How to to pass a path which has space in folder name to system function.

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by Sam557
0

Try escaping some " " and putting them in your path, so it treats it as if the filename was in quotes at the prompt:
"java -jar \"/Users/User1/Desktop/Sample Java/Demo.jar\" ";

If not try"java -jar /Users/User1/Desktop/Sample%20Java/Demo.jar ";
but I'm not confident it will work (it will probably just insert the space all over again).

0

Try escaping some " " and putting them in your path, so it treats it as if the filename was in quotes at the prompt:
"java -jar \"/Users/User1/Desktop/Sample Java/Demo.jar\" ";

If not try"java -jar /Users/User1/Desktop/Sample%20Java/Demo.jar ";
but I'm not confident it will work (it will probably just insert the space all over again).

It works for me too i just follow your work:
Syntax for c++ :

#include <windows.h>
int main ()
{
system("C:\\Junk\\Raptor\" Connector\\input.txt\"");
//	OR
system("C:\\Junk\\\"Raptor Connector\\input.txt\"");
  return 0;
}

Edited by Sam557: good look

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.