title: alternatives --config java bash script
body: <p>I am writing a script that installs java on a remote machine. After i run the .bin file for the JRE, how can i set the alternatives --config java without the user having to input anything.</p>
  
  <p>For instance, when you type in "alternatives --config java" you are prompted to select which java version you would like. Due to the way i installed java ("/usr/sbin/alternatives --install /usr/bin/java java /location/of/jdk1.6/bin/java 2") the #"2" option should always be the java that i want selected.</p>
  
  <p>So, using an ssh command execution, how can i select the second option for java alternatives without the user having to choose the option. I want it fully automated.</p>
  
  <p>This is in a bash script.</p>
  
  <p>Thanks</p>
  
  <hr>
  
  <p>Below is the code (working correctly now):</p>
  
  <pre><code>#install the jre
  sshRetValue=`ssh -p "22" -i $HOME/sshids/idrsa-1.old ${1} " /home/geiser/jms_adapter/jre-6u25-linux-i586.bin "`;
  sshRetValue=`echo $?`;
  if [ "$sshRetValue" -eq 0 ];then
          echo "java jre installed successfully";
          #set the alternative and stuff if needed
          ssh -p "22" -i $HOME/sshids/idrsa-1.old ${1} " /usr/sbin/alternatives --install /usr/bin/java java /root/jre1.6.0_25/bin/java 2 ";
          echo 2 | ssh -p "35903" -i $HOME/sshids/idrsa-1.old ${1} " alternatives --config java ";
  else
          echo "java jre installation failed";
  fi
  </code></pre>