System.getenv() returning

I’m trying to make a path to a place on the computer with the System.getenv function and it returns a in the path not a / which is what I need. I have tried with the replaceAll method but it returns a error:

Exception in thread "main" java.util.regex.PatternSyntaxException: Unexpected internal error near index 1

    at java.util.regex.Pattern.error(Unknown Source)
    at java.util.regex.Pattern.compile(Unknown Source)
    at java.util.regex.Pattern.<init>(Unknown Source)
    at java.util.regex.Pattern.compile(Unknown Source)
    at java.lang.String.replaceAll(Unknown Source)
    at Launcher.start(
    at Launcher.Download(
    at Launcher.<init>(
    at Launcher.main(

the line of code is:

InputStream OS = Runtime.getRuntime().exec(new String[]{"java",System.getenv("APPDATA").replaceAll("\", "/")+"/MS2-torsteinv/MS2-bin/no/torsteinv/MarsSettlement2/Client/Client.class"}).getErrorStream();


You need to double the backslash:

.replaceAll("\\", "/")

The canonical regex is indeed \, but in Java regexes are in strings, and in Java strings, a literal backslash needs to be escaped with another backslash. Hence \ becomes "\\".