title: The filename, directory name, or volume label syntax is incorrect java
body: <p>So i'm currently trying to add a <code>Security Certificate</code> that i have to the Java <code>Keystore</code>. I can do this easily on <code>cmd</code> using the value stored inside the String <code>temp</code>, but I want to be able to do this inside my java code. I'm using the following code to do it, but I get the following error <code>The filename, directory name, or volume label syntax is incorrect.</code></p>
  
  <pre><code>    String java_Home = System.getProperty("java.home");
      java_Home = java_Home + "\\lib\\security";
      java_Home = java_Home.trim();
  
      String temp = "..\\..\\bin\\keytool -import -trustcacerts -keystore cacerts -storepass changeit -noprompt -alias RandomKeyName -file C:\\Users\\Chris\\Desktop\\RandomKey.crt";
      temp = temp.trim();
  
      String[] commands = {"cmd.exe", "/c", "cd " + java_Home, temp};
  
      ProcessBuilder builder = new ProcessBuilder(commands);
      builder.redirectErrorStream(true);
      Process p = builder.start();
      builder.command();
      BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
      String line;
      while (true) {
          line = r.readLine();
          if (line == null) {
              break;
          }
          System.out.println(line);
      }
  </code></pre>
  
  <p>I have looked up this error and found the following page on the error <a href="https://technet.microsoft.com/en-us/library/cc956689.aspx" rel="nofollow">https://technet.microsoft.com/en-us/library/cc956689.aspx</a>., but i still haven't been able to solve the problem. I know it is something small but I just can't see it. Does anyone know how  to fix this?</p>