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

此生再无相见时 提交于 2019-11-28 03:19:47
Francois

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

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

King_SaGo

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.

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

Tom Jowitt

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

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.

In windows Create new environment as STUDIO_JDK which refers to your jdk C:\Program Files\Java\jdk1.7.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

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.

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/

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!