title: Chef-Client tries to install Java on Windows but it is already installed
body: <p>I'm new to Chef and want to install Java on a windows machine with it.</p>
  
  <p>There is a ready-to-use <a href="https://github.com/agileorbit-cookbooks/java" rel="nofollow noreferrer">Java cookbook</a> I'm using.</p>
  
  <p>So I wrote a wrapper cookbook, as mentioned in <a href="https://stackoverflow.com/questions/28776899/can-the-java-cookbook-be-used-to-install-a-local-copy-of-oracle-java">another question here</a>.</p>
  
  <p>I added the java-cookbook-dependencies and used the following attributes at </p>
  
  <h2>attribute/java.rb</h2>
  
  <pre><code>normal['java']['jdk_version'] = '7'
  normal['java']['install_flavor'] = 'windows'
  normal['java']['windows']['url'] = 'http://myurl/java/jdk-7u75-windows-x64.exe'
  </code></pre>
  
  <p>So after uploading the cookbook and adding it into the runlist Java gets installed and is available. But whenever I run the chef-client, it tries to install the JDK from the file again. </p>
  
  <h2>So my question:</h2>
  
  <p>Am I missing some configuration to check for an already installed version? For my understanding, this should be done in the <a href="https://github.com/agileorbit-cookbooks/java" rel="nofollow noreferrer">given cookbook</a>, but Im not sure if it is. </p>
  
  <p>I also tried to declare a package name, but this does not change anything.</p>
  
  <pre><code>normal['java']['windows']['package_name'] = 'OracleJDK7u75'
  </code></pre>
  
  <p>Here the (relevant) output after starting the chef client with knife:</p>
  
  <pre><code>WindowsPC [2015-04-10T14:38:06+02:00] INFO: Processing remote_file[c:/chef/cache/jdk-7u75-windows-x64.exe]action create (java::windows line 45)
  WindowsPC [2015-04-10T14:38:08+02:00] INFO: Processing windows_package[OracleJDK7u75] action install (java::windows line 71)
  WindowsPC [2015-04-10T14:38:09+02:00] INFO: Installing windows_package[OracleJDK7u75] version latest
  WindowsPC [2015-04-10T14:38:09+02:00] INFO: Starting installation...this could take awhile.
  WindowsPC
  WindowsPC ================================================================================
  WindowsPC Error executing action `install` on resource 'windows_package[OracleJDK7u75]'
  WindowsPC ================================================================================
  WindowsPC
  WindowsPC Mixlib::ShellOut::ShellCommandFailed
  WindowsPC ------------------------------------
  WindowsPC Expected process to exit with [0, 42, 127], but received '1603'
  WindowsPC ---- Begin output of start "" /wait "c:\chef\cache\jdk-7u75-windows-x64.exe" /s  &amp; exit %%ERRORLEVEL%% ----
  WindowsPC STDOUT:
  WindowsPC STDERR:
  WindowsPC ---- End output of start "" /wait "c:\chef\cache\jdk-7u75-windows-x64.exe" /s  &amp; exit %%ERRORLEVEL%% ----
  WindowsPC Ran start "" /wait "c:\chef\cache\jdk-7u75-windows-x64.exe" /s  &amp; exit %%ERRORLEVEL%% returned 1603
  WindowsPC
  WindowsPC Cookbook Trace:
  WindowsPC ---------------
  WindowsPC c:/chef/cache/cookbooks/windows/libraries/windows_package.rb:109:in `install_package'
  WindowsPC c:/chef/cache/cookbooks/windows/libraries/windows_package.rb:31:in `block in &lt;class:WindowsCookbookPackage&gt;'
  WindowsPC
  WindowsPC Resource Declaration:
  WindowsPC ---------------------
  WindowsPC # In c:/chef/cache/cookbooks/java/recipes/windows.rb
  WindowsPC
  WindowsPC  71: windows_package node['java']['windows']['package_name'] do
  WindowsPC  72:   source cache_file_path
  WindowsPC  73:   checksum node['java']['windows']['checksum']
  WindowsPC  74:   action :install
  WindowsPC  75:   installer_type :custom
  WindowsPC  76:   options "/s #{additional_options}"
  WindowsPC  77: end
  WindowsPC
  WindowsPC Compiled Resource:
  WindowsPC ------------------
  WindowsPC # Declared in c:/chef/cache/cookbooks/java/recipes/windows.rb:71:in `from_file'
  WindowsPC
  WindowsPC windows_cookbook_package("OracleJDK7u75") do
  WindowsPC   provider Chef::Provider::WindowsCookbookPackage
  WindowsPC   action [:install]
  WindowsPC   retries 0
  WindowsPC   retry_delay 2
  WindowsPC   default_guard_interpreter :default
  WindowsPC   declared_type :windows_package
  WindowsPC   cookbook_name "java"
  WindowsPC   recipe_name "windows"
  WindowsPC   source "c:/chef/cache/jdk-7u75-windows-x64.exe"
  WindowsPC   installer_type :custom
  WindowsPC   options "/s "
  WindowsPC   package_name "OracleJDK7u75"
  WindowsPC   timeout 600
  WindowsPC   success_codes [0, 42, 127]
  WindowsPC end
  WindowsPC
  WindowsPC [2015-04-10T14:38:14+02:00] INFO: Running queued delayed notifications before re-raising exception
  WindowsPC [2015-04-10T14:38:14+02:00] ERROR: Running exception handlers
  WindowsPC [2015-04-10T14:38:14+02:00] ERROR: Exception handlers complete
  WindowsPC [2015-04-10T14:38:14+02:00] FATAL: Stacktrace dumped to c:/chef/cache/chef-stacktrace.out
  WindowsPC [2015-04-10T14:38:14+02:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: windows_package[OracleJDK7u75] (java::windows line 71) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0, 42, 127], but received '1603'
  WindowsPC ---- Begin output of start "" /wait "c:\chef\cache\jdk-7u75-windows-x64.exe" /s  &amp; exit %%ERRORLEVEL%% ----
  WindowsPC STDOUT:
  WindowsPC STDERR:
  WindowsPC ---- End output of start "" /wait "c:\chef\cache\jdk-7u75-windows-x64.exe" /s  &amp; exit %%ERRORLEVEL%% ----
  WindowsPC Ran start "" /wait "c:\chef\cache\jdk-7u75-windows-x64.exe" /s  &amp; exit %%ERRORLEVEL%% returned 1603
  ERROR: Failed to execute command on     WindowsPC return code 1   
  </code></pre>
  
  <p>Thank you in advance</p>
  
  <p>Bohne</p>