Hi
I am trying to install Java 8 on windows. By default, it is installing in directory "C:\Program files\Java". But I want to install the java at another location.
Kindly help me out. Find the below chef code to install Java8
# Download Java_8 from remote directory on chef-client node
remote_file "#{Chef::Config['file_cache_path']}/jdk.exe" do
source "#{node['shared_resources']['java_8']['download_url']}"
remote_domain "#{node['shared_resources']['domain']}"
remote_user "#{node['shared_resources']['user_name']}"
remote_password "#{node['shared_resources']['password']}"
end
execute "Java" do
cwd "#{Chef::Config['file_cache_path']}"
command "jdk.exe"
end
windows_env 'JAVA_HOME' do
value "#{ENV['ProgramW6432']}\\Java\\#{node['java']['directory_name']}"
end
# Set the path of JAVA_HOME in in PATH environment variable
windows_env 'Path' do
value "#{ENV['ProgramW6432']}\\Java\\#{node['java']['directory_name']}\\bin\\;#{ENV['Path']}"
action :modify
end
# delete jdk-8u181-windows-x64.exe
file "#{Chef::Config['file_cache_path']}/jdk.exe" do
action :delete
end
Regards,
Deepak