title: When and Why run alternatives --install java jar javac javaws on installing jdk in linux
body: <p>To install java in linux (I used CentOS, RHEL is same too), I used this command</p>
  
  <p><code>rpm -Uvh /path/to/binary/jdk-7u55-linux-x64.rpm</code></p>
  
  <p>and verified java </p>
  
  <p><code>java -version</code></p>
  
  <p>Looking at a tutorial, it says to run following 4 commands, not sure why</p>
  
  <pre><code>## java ##
  alternatives --install /usr/bin/java java /usr/java/latest/jre/bin/java 200000
  ## javaws ##
  alternatives --install /usr/bin/javaws javaws /usr/java/latest/jre/bin/javaws 200000
  
  ## Install javac only
  alternatives --install /usr/bin/javac javac /usr/java/latest/bin/javac 200000
  ## jar ##
  alternatives --install /usr/bin/jar jar /usr/java/latest/bin/jar 200000
  </code></pre>
  
  <p>I know if there are multiple versions of java installed, you can select version to use from </p>
  
  <pre><code>alternatives --config java
  </code></pre>
  
  <p>then why to run <code>alternative --install</code> separately for each executable.</p>
  
  <p>I've seen 
  <a href="https://stackoverflow.com/questions/16416037/why-is-alternatives-command-used-when-installing-java-on-a-linux-machine">this</a> question but doesn't get my answer</p>