#!/bin/bash

JAVA_SELECTED=/usr/lib/jvm/selected
JAVA6=/usr/lib/jvm/java-1.6.0-openjdk
JAVA7=/usr/lib/jvm/java-7-openjdk-i386

# init on first run
[ ! -L $JAVA_SELECTED ] && ln -sfn $JAVA7 $JAVA_SELECTED
[ ! -L $JAVA_SELECTED/bin/java ] && ln -sf $JAVA_SELECTED/bin/java /usr/local/bin/java
[ ! -L $JAVA_SELECTED/bin/javaws ] && ln -sf $JAVA_SELECTED/bin/javaws /usr/local/bin/javaws

#ls -la $JAVA_SELECTED

if readlink $JAVA_SELECTED | grep -q 1.6; then
  ln -sfn $JAVA7 $JAVA_SELECTED
  echo java7
else
  ln -sfn $JAVA6 $JAVA_SELECTED
  echo java6
fi

read -n 1 -r -p "Press any key to continue..." dummy
  
  
  

