Android Studio 'tools.jar' file is not present in classpath
Asked Answered
P

11

46

I downloaded the current version of Android Studio (latest as of 4th July 2013) I also downloaded the JDK version 7u25.

However, it displays error after startup: Please ensure JAVA_HOME points to JDK rather than JRE.

I don't know how to solve this problem, which won't let me run the IDE. I would appreciate any help.

Polythene answered 4/7, 2013 at 16:35 Comment(2)
possible duplicate of Error to run Android StudioAuxiliaries
Hi there can you please accept my awnser if it helped you, tx :)Banal
B
75

Check if java JDK is installed correctly

dpkg --list | grep -i jdk

if not install JDK

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update && sudo apt-get install oracle-jdk7-installer

After the installation you have enable the jdk

update-alternatives --display java

Check if Ubuntu uses Java JDK 7

java -version

If all went right the answer should be something like this:

java version “1.7.0_25″
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) Server VM (build 23.3-b01, mixed mode)

Check what compiler is used

javac -version

It should show something like this

javac 1.7.0_25

Add JAVA_HOME to environment variable

Edit /etc/environment and add JAVA_HOME=/usr/lib/jvm/java-7-oracle to the end of the file

sudo nano /etc/environment

Append to the end of the file

JAVA_HOME=/usr/lib/jvm/java-7-oracle

Log in and out (or reboot) for the changes to take effect.

If you want to remove oracle JDK

sudo apt-get remove oracle-jdk7-installer
Banal answered 24/7, 2013 at 7:25 Comment(3)
thank you so much I was getting an error: "tools.jar' seems to be not in IDEA classpath. Please ensure JAVA_HOME points to JDK rather than JRE" turns out I didn't have the JDK correctly installed through the ubuntu software center since javac was throwing an error. I ran /opt/idea-IC-135.480/bin$ sudo apt-get install openjdk-7-jdk and it's working perfect now!Geri
Thanks advocate, that worked. Mine system is Ubuntu 14.04, and I had installed openjdk-7 from the Ubuntu software center. Running sudo apt-get install openjdk-7-jdk from the bin directory of the unpacked Intellij download did the trick.Ichang
I still had the same error after following these steps. However, I had openJDK installed. So I purged openJDK using the instructions from here: askubuntu.com/questions/335457/how-to-uninstall-openjdk. Then I followed these steps again, installing oracle JDK instead. Now it works!Tristis
F
21

read this: http://arwankhoiruddin.blogspot.co.il/2014/01/android-studio-in-ubuntu-problem.html

in short: type at the terminal

$ sudo update-alternatives --config java

now you need to choose

usr/lib/jvm/java-7-openjdk/jre/bin/java

by pressing #3

Furbish answered 29/4, 2014 at 13:53 Comment(2)
Thanks, this was much easier than the top voted answer. I knew I had java-7 installed, just needed to select it as the default.Escolar
Easier this way, thanks. Btw, how to get acquainted with commands like this? In the first place how to know what command to use for what?! uff.Mature
F
15

I have Ubuntu 14.04 and OpenJDK and for me a fresh install worked.

just did

sudo apt-get install openjdk-7-jdk

or,

sudo apt-get install --reinstall openjdk-7-jdk if it is already installed and giving error,

and everything was fine.

Flowering answered 20/2, 2015 at 16:43 Comment(0)
F
13

On ubuntu I have tried all the methods that are described here but none worked.

What I did in the end was to:

  • download JDK from oracle and extract the archive

  • edit android-studio/bin/studio.sh and add at the top

    export JAVA_HOME=/path/to/jdk

  • save the file and cd android-studio/bin and launch Android Studio: ./studio.sh

Feinberg answered 13/1, 2015 at 9:36 Comment(1)
Thank you. This worked for me whereas editing /etc/environment as suggested in the top answer simply had no effect even after rebooting. Maybe the Android studio team could have come up with a more explicit message and a dialog to select the path to your JDK?Pottle
T
5

On Fedora (and other RedHat derivatives, e.g. RHEL 7 and CentOS 7), it was the missing openjdk-devel package that was the issue for me. It's an easy fix and nothing to do with the JAVA_HOME path or the JRE.

sudo yum install java-1.7.0-openjdk-devel.x86_64
Touristy answered 21/12, 2014 at 7:33 Comment(1)
Thanks! Just as a note, on Fedora 23 and for Java 8, this can be achieved with sudo dnf install install java-1.8.0-openjdk-develDesiccator
B
4

If you are using Windows, the installation can be confusing for many users...

The installer lets you specify an installation path, but this is only if you have the JRE option selected to install.

The actual JDK installs automatically to...

C:\Program Files\Java\jdkX.XX on 64-bit

C:\Program Files (x86)\Java\jdkX.XX on 32-bit

So you need to make sure you set the JAVA_HOME variable in environment variables set to this JDK path, not the JRE path that appears in the installer.

Brigitta answered 18/11, 2014 at 4:24 Comment(0)
V
2

In windows Create new environment as STUDIO_JDK which refers to your jdk C:\Program Files\Java\jdk1.7.0

Venerate answered 31/3, 2015 at 7:43 Comment(0)
S
0

This answer may be very specific to a Windows 7 32 bit system: Even after setting the JAVA_HOME variables, I had problems. After installing the JAVA again from the website, http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

BUT THIS TIME I TRIED "Windows x64 54 MB jdk-8u51-windows-x64-demos.zip" which seems to be for 64 bit even though my system is 32 bit and the ANDROID STUDIO started working for me. My environment settings are following (under System variables and not under user variables):

JAVA_HOME-C:\Program Files (x86)\Java\jre1.8.0_51 JDK_HOME-C:\Program Files (x86)\Java\jdk1.8.0_51

Saline answered 22/7, 2015 at 5:31 Comment(0)
S
0

I had the same problem on Linux Mint 17.2 and it was very simple:

In the package manager I found that openjdk-7-jre was installed but not the JDK. All I had to do was to install openjdk-7-jdk.

As I'm new to Linux it took me some time to figure this out though because I assumed by the name of the path /usr/lib/jvm/java-7-openjdk-amd64 that it was already the JDK but it was just the JRE.

Studious answered 25/8, 2015 at 21:2 Comment(0)
G
0

On Linux Mint 17 (or Ubuntu 14.04):

sudo apt-get install openjdk-7-jdk

Then change the JAVA_HOME env variable.

export JAVA_HOME=JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/
Gourd answered 11/4, 2016 at 6:42 Comment(0)
O
0

Downloading the latest Android Studio resolve this issue / OSX /MAC

Octans answered 1/2, 2018 at 22:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.