The command
$ ~/android-studio/bin/studio.shsays
'tools.jar' seems to be not in Android Studio classpath. Please ensure JAVA_HOME points to JDK rather than JRE.I have searched for the solution to this error, and as far as I can tell, I've done everything right to correct this error. But it still persists.
sudo apt-get install openjdk-7-jdk(CHECK)JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64(CHECK)sudo update-alternatives --config java* 0 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 auto modefind /usr/lib/jvm | grep tools.jar- finds nothing. (FAIL)
What am I missing?
17 Answers
As per output mentioned for command
sudo update-alternatives --config javaI can see that you have only JRE installed but you also need JDK to compile and run the code.
You can install JDK for Java 8 using following command :
sudo apt-get install openjdk-8-jdkAnd then run
sudo update-alternatives --config javacommand and select JDK instead of JRE.
I was getting the same error, and found that I did not have the java compiler installed.
Try javac -version and see if you have it installed. If not,
sudo apt-get install openjdk-7-jdkand hopefully that will fix your problem.
EDIT: I see now after rereading that you have already installed the jvm once, but I had it installed as well, so I'm not sure if something got updated or what but like I said it worked for me.
1I had the same problem. There has nothing to do on JAVA_HOME or configure-alternatives. The truth is there is no tools.jar in oracle-java-9(even in open-jdk). To use android-studio in the Ubuntu you must use java-8. Why? I don't know and I don't care! I must to learn Android Studio, so whatever...
Install jdk-8 for android-studio, change PATH and JAVA_HOME environment and be happy!
Works for me...
sudo apt install openjdk-8-jdk-headless because studio.sh is a script itself, running JAVA_HOME=.. is not enough. Instead, make sure you run:
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
Maybe you have a Oracle JDK installed and conflicted with OpenJDK, use:
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
IN LINUX DEBIAN :
1.- Open Synaptic and search "openjdk".
2.- checks that do not have more than one installed version of the package "openjdk-?".
3.- uninstall all file with old version and left alone all file with new version.
4.- Check that your Java Version have change from terminal "#java -version".
5.- try again install studio.sh