title: Removing old java paths - Puppet
body: <p>We are having an issue with the puppet java modules. They are adding the correct path, but they do not remove the old path:</p>
  
  <blockquote>
    <p>C:\Windows\system32>path
    PATH=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program
    Files (x86)\IBM\RationalSDLC\common;;C:\Program Files
    (x86)\NTP\bin;C:\Program Files (x86)\Puppet Labs\Puppet\bin;C:\Program
    Files\Java\jdk1.7.0_50\bin;C:\PROGRA~1\apache-maven\bin;C:\Program
    Files\Java\jdk1.7.0_55\bin</p>
  </blockquote>
  
  <p>You can see that it added the correct path at the end, but the original version jdk1.7_50\bin still exists. How can we make sure that it removes the old version every time it installs a newer version?</p>
  
  <p>Edit: More importantly what we need to do is have it search for the <code>JAVA_HOME</code> path variable, compare that against <code>Path</code> variable, delete any java directory that doesnt belong, and copy the <code>JAVA_HOME</code> to <code>Path</code>. Hope that makes sense.</p>