Tyler Fitch

Installing Sun Java 1.5 with Chef

• Tyler Fitch • chef and java

In trying to use the Chef community cookbook for Java I found it to only work with Java 6 and Java 7.

I was trying to create a cookbook to recreate an existing environment at work I need a scripted install of the Sun 1.5 JDK.

So I had to bail entirely on the community cookbook and go my own route.  Here’s how it played out.

remote_file "/install/location/path/jdk-1_5_0_XYZ-linux-i586.bin" do
source "http://your.artifactory.example.com/artifactory/yourRepo/jdk-1_5_0_XYZ-linux-i586.bin"
mode "0700"
not_if { ::File.exists?('/install/location/path/jdk-1_5_0_XYZ-linux-i586.bin') }
bash "install-jdk15" do
cwd "/install/location/path"
code <<-EOH
./jdk-1_5_0_XYZ-linux-i586.bin >/dev/null < <(echo yes) >/dev/null < <(echo yes)
rm -rf /install/location/path/jdk1.5.0_XYZ/sample
rm -rf /install/location/path/jdk1.5.0_XYZ/demo
ln -s /install/location/path/jdk1.5.0_XYZ /install/location/path/java
not_if { ::File.exists?('/install/location/path/jdk1.5.0_XYZ/README.html') }
magic_shell_environment 'JAVA_HOME' do
value '/install/location/path/java'

One thing this does not do is put the java and/or javac executables in to your $PATH.  I’d do this like the Java cookbook does and do symlinks to /usr/local/bin if you need it.

comments powered by Disqus