I want to add a new entry in my windows registry. I’m using the following code:
String start_cmd = JAVABIN + " -jar " + outputJar.getAbsolutePath();
ProcessBuilder pb = new ProcessBuilder(new String[]{"REG", "ADD", REGENTRY, "/v", "Vodemki_app", "/d", "\"" + start_cmd + "\"", "/f"});
pb.start();
So REGENTRY is my reg path (ex: HKEY_LOCAL_MACHINE\\SOFTWARE\\....
start_cmd is a command that starts my jar file. It works well if my absolute path does NOT contain any space. But if I use a path like C:\\Vodemki\\Desktop\\My Folder\\jarfile.jar, everything goes wrong.
So my question is: Is there a way to use a path with space using my code? I know it’s possible to use \"my path\"but is there a way to do that into escaped quote (ex: \"java -jar \"my path with spaces\" \")?
Thanks.
Solution was quiet simple, replace the space char with
\s.Regards.