There is a tricky problem about
JAVA_HOME. When I try to install android studio on my Linux, the installer reports the following message:
tools.jar is not in android studio classpath. Please ensure JAVA_HOME points to JDK rather than JRE.
However, JDK has already been installed and I have added the following lines in
/etc/profile to export the variables.
JAVA_HOME is pointing to the JDK, but why it is not working on android studio?
The answer is: the correct place to declare
/etc/environment, rather than
/etc/profile. Although those two files have similar functions, there is an important different.
/etc/environment is used for setting variables for programs which are not started from a shell. Since android studio installer is a set of complex programs, it only relies on
/etc/environment to obtain
JAVA_HOME variable, so
/etc/environment is the place to declare
The solution is easy. Append the following line in
/etc/environment and everything works fine!