title: How to find if jre or jdk is installed in Mac and if not install jre using shell script
body: <p>Before I install a Java application on any client machine (Mac OSX >10.5), I would like to first see if either JDK or JRE is installed already in the machine. If JRE/JDK is not present, I want to install JRE in that machine and then proceed with the actual application installation.</p>
  
  <p>Was wondering how to write a shell script to find if Java is already installed in the client machine, and conditionally proceed with rest of the installation. Any pointers to built-in tools/ sample code will help.</p>