title: How can I set the System Time in Java?
body: <p>Is it possible to change the System Time in Java?  </p>
  
  <p>It should run under Windows and Linux. I've tried it with the <code>Runtime</code> Class in but there is a problem with the permissions.</p>
  
  <p>This is my code:</p>
  
  <pre><code>String cmd="date -s \""+datetime.format(ntp_obj.getDest_Time())+"\"";
  try {
      Runtime.getRuntime().exec(cmd);
  } catch (IOException e1) {
  // TODO Auto-generated catch block
    e1.printStackTrace();
  }
  System.out.println(cmd);
  </code></pre>
  
  <p>The output of <code>cmd</code> is:</p>
  
  <pre><code>date -s "06/01/2011 17:59:01"
  </code></pre>
  
  <p>But the System time is the same as before.</p>
  
  <p>I will set the time because I am writing an NTP-Client and there I get the time from a NTP-Server and will set it. </p>