title: symlink installed java to /usr/java/latest
body: <p>A program requires a java directory location of <code>/usr/java/latest</code>. In many cases this directory does not exist. In order to get the program to run correctly I need to do the following steps:</p>
  
  <pre><code>mkdir -p /usr/java
  mkdir -p /usr/java/latest
  </code></pre>
  
  <p>Then I need to find what java installations are available and symlink them to the above directories:</p>
  
  <pre><code>ll /usr/lib/jvm
  </code></pre>
  
  <p>I usually choose the latest directory avialable...ie:</p>
  
  <pre><code>drwxr-xr-x. 3 root root   16 Feb 12  2016 java-1.8.0-openjdk-1.8.0.71-2.b15.el7_2.x86_64
  </code></pre>
  
  <p>and then create a link to /usr/java/latest</p>
  
  <pre><code>ln -s /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.71-2.b15.el7_2.x86_64/jre/lib /usr/java/latest/lib
  ln -s /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.71-2.b15.el7_2.x86_64/jre/bin /usr/java/latest/bin
  </code></pre>
  
  <p>I am trying to create an installation script that automates the above process without having to copy and paste the directory name for the symbolic link. Basically I want to parse the /usr/lib/jvm/ directory for the most recent (or any) available java directory. Then I want to take that and link the lib and bin directories within that directory to the /usr/java/latest directory. Thank you in advance for any type of advice. </p>