6

The command

$ ~/android-studio/bin/studio.sh

says

'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.

  1. sudo apt-get install openjdk-7-jdk (CHECK)
  2. JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 (CHECK)
  3. sudo update-alternatives --config java

    * 0    /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java   1071   auto mode
    
  4. find /usr/lib/jvm | grep tools.jar

    • finds nothing. (FAIL)

What am I missing?

1

7 Answers 7

6

As per output mentioned for command

sudo update-alternatives --config java

I 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-jdk

And then run

sudo update-alternatives --config java

command and select JDK instead of JRE.

2

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-jdk

and 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.

1
  • You saved my day. I had installed JRE, but not JDK. Used above command to install JDK and it worked. Apr 6, 2018 at 10:31
2

I 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...

2
sudo apt install openjdk-8-jdk-headless
1

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

0

Maybe you have a Oracle JDK installed and conflicted with OpenJDK, use:

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

-1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .