FANDOM


Switching JVMsEdit

So here is a script I wrote that manages a symbolic link such that one can switch their JVM out easily. This way your settings for your .bash_profile never need to be changed.

#!/bin/bash
set -e 

JDKDIR="/opt/jdks/" #Must end in a / 

echo "Available jdks: "
echo

ctr=0

for I in `ls ${JDKDIR} | grep jdk`;do 
 if [[ -d ${JDKDIR}${I} ]];then
   let "ctr +=1"
   echo ${ctr}. ${JDKDIR}${I}
 fi
done
ctr=0
echo
echo Choose:
read response

for I in `ls ${JDKDIR} | grep jdk`;do

 if [[ -d ${JDKDIR}${I} ]];then
   let "ctr +=1"
   if [[ ${ctr} == ${response} ]];then

     rm -f "$HOME/bin/java"
     ln -s "${JDKDIR}${I}/bin" "$HOME/bin/java"

   fi
 fi

done

For those who prefer a more standardized Linux approach, I'm going to look into using the etc/alternatives system for this one day soon.

Commands of interest are:

update-alternatives --config java

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.