I tried to get the Android Studio launcher (studio.sh) to use my manually installed Java (not the system-wide default Java). Since I already declared PATH
and JAVA_HOME
in my .bashrc
file, I simply sourced that file in the shell script:
. /home/foobar/.bashrc
but for some reason, $JAVA_HOME/bin/java
was still not recognized as an executable file by the script.
I added some logging and found out that JAVA_HOME
was expanded as ~/install/java..., i.e. the tilde operator was not expanded into the home directory.
I did some searching, but couldn't find any reason why it was not expanded. Is tilde a Bash-specific feature (the script uses #!/bin/sh
, and Linux Mint uses dash, not bash)? Does tilde not work in some circumstances?
I replaced ~
with $HOME
in my .bashrc
declaration, and then it worked, so HOME is known at runtime.