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.
- Download the installer you need. In my case the .bin file - without the rpm, just the bin.
- Upload the .bin to your Artifactory server so everyone can easily get access to it when building their VMs.
- Get the installer on to the VM using Chef remote_file command with mode 0700 to ensure the installer is executable.
- Run the bash command to run the installer
- The installer requires acceptance of the EULA. So scripting this was a pain. Hat tip to Kule on linuxquestions.com - http://www.linuxquestions.org/questions/linux-newbie-8/java-jdk-silent-install-help-891313/#post4433389
- The EOH here is important - for me EOF did not work for the command attribute.
- Using the magic_shell cookbook - create a environment variable $JAVA_HOME just like the Java cookbook would and many Java apps now expect to exist.
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.