title: Script to Change JAVA_HOME System Variable in Windows
body: <p>I do most of my work against JDK 1.5 - but occasionally I have to change to 1.6. it is a bit painful to have to manually go and change my 'JAVA_HOME' system variable whenever I need to work on a project specific to one or the other (and no, Eclipse doesn't play well in these scenarios - trust me...I've tried.)</p>
  
  <p>I'm looking for a registry script or windows shell script or for that matter any means by which I can "toggle" this system variable with something that is easy to run. </p>
  
  <p>I've messed with the 'set' command, but that only sets the variable for that particular command instance - not globally. </p>
  
  <p>Thanks in advance.</p>
  
  <p>EDIT #1: 
  Points of advise: </p>
  
  <ul>
  <li>Use the <strong>JAVA_HOME</strong> variable in your path variable as well, that way you only have to change the <strong>JAVA_HOME</strong> (which is used in many projects anyways [maven, ant, etc]) </li>
  <li>Write the command into a couple batch scripts for easy use</li>
  <li>When you make the change the windows command session will not reflect it right away. You must close and reopen it.</li>
  </ul>