I am trying to set my Java version by passing the version to a function. However, I am not sure how I can substitute the bash argument in the command. Below is the function I am using
function setTheJavaVersion(){
export JAVA_HOME=`/usr/libexec/java_home -v '$1*'`
}
I am calling the function as -
setTheJavaVersion 1.7
The 1.7 is stored in "$1" but as expected I get the error message -
Unable to find any JVMs matching version "$1*".
Not a bash expert so excuse me if its a silly question.