Search code examples
javacommandexeccommand-window

Java Invalid escape sequences


I have this error : "Invalid escape sequences (valid ones are \b \t ..." in my code Java.

I make in my code.java :

    ...
    r.exec("cmd /c D:\Doc and Settings\USER\Bureau\Apps-Two.loc.nal");
    ...

The problem is the escapes. How resolve this problem ?

Thank you


Solution

  • r.exec("cmd /c D:\Doc and Settings\USER\Bureau\Apps-Two.loc.nal"); // Compiler not able to understand this backslash.
    

    you should use "\\" wherever you want to use actual backslash (\)

    change your folder path like this

    r.exec("cmd /c D:\\oc and Settings\\USER\\Bureau\\Apps-Two.loc.nal");

    See the attached table for your reference

    enter image description here