44

After ./studio.sh in a terminal I get this error "tools.jar is not in android studio classpath Please ensure JAVA_HOME points to JDK rather than JRE".

I Google it and this is what everybody says: "you need to set your environment variable to JDK path instead of JRE"

I try this two commands

export PATH=${JDK_HOME}:/etc/java-7-openjdk

export PATH=${JAVA_HOME}:/etc/java-7-openjdk

And execute again ./studio.sh and I get the same error

My OS is Linux Mint 14

Padma Kumar
  • 19,893
  • 17
  • 73
  • 130
Bryan Villafañe
  • 678
  • 3
  • 8
  • 18

12 Answers12

84

I solved the problem combining Jerome's and Jarod's answer:

  1. Install JDK -- sudo apt-get install openjdk-7-jdk
  2. Environment Variable -- sudo nano /etc/environment adding the following line:
  3. JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-i386
  4. Reboot, and Android Studio starts up. (I had added also a link to studio.sh to the main menu).

Also I just found https://stackoverflow.com/a/17827697/2533809 which seems to have a nice write-up, pretty much the same answer.

(I'm using Debian 7 Wheezy)

Community
  • 1
  • 1
dajon
  • 2,350
  • 1
  • 16
  • 17
  • 17
    For x64 JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64 – Mate Jan 26 '14 at 01:16
  • 3
    if you dont have admin rights, you can also `export JAVA_HOME=/usr/lib...` as a command, or in your .$(shell)rc – hr0m Jun 15 '14 at 17:23
  • 1
    You can also just logout and login instead of rebooting – personne3000 Aug 24 '14 at 02:47
  • Event with `JAVA_HOME` properly set, still the same error. – Hibou57 Feb 09 '16 at 00:05
  • OK, I was misled by the JDK directory being there, while no JDK was installed (strange). I installed the JDK, and it's OK (just wonder why this JDK directory was there while there was no JDK). – Hibou57 Feb 09 '16 at 00:20
10

I have figured it out. You need to install openjdk-jdk. Opensjdk-jre is not enough. So in terminal all you need to do is write sudo apt-get install openjdk-7-jdk then press yes. Open the android studio bin folder, double click on studio.sh, open in terminal, press enter, and then android studio should work.

Jerome
  • 167
  • 1
  • 12
  • 1
    This works like a charm and is a lot less hassle than the other alternatives. Might not work for everyone, but worth trying before editing a lot of files. – Watercolours Apr 07 '15 at 11:26
6

Here's how I solved the same problem in my system: Thanks for @user2533809

$sudo apt-get install openjdk-7-jdk
$ls /usr/lib/jvm/java-1.7.0-openjdk-i386
ASSEMBLY_EXCEPTION  bin  docs  include  jre  lib  man  THIRD_PARTY_README
$export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-i386
$./studio.sh 

Environment :

kesavan@kesavan-Ideapad-Z460:bin$ uname -a
Linux kesavan-Ideapad-Z460 3.2.0-59-generic-pae #0trisquel1 SMP Sat Feb 22 03:55:17 UTC 2014 i686 i686 i386 GNU/Linux
kesavan@kesavan-Ideapad-Z460:bin$ 
5

You must be sure that your jre and jdk works fine.

Run

$ sudo apt-get install default-jre

and then...

$ sudo apt-get install default-jdk

to make sure you have your javac path run

$ whereis javac

It should return something like this:

javac: /usr/bin/javac /usr/bin/X11/javac /usr/share/man/man1/javac.1.gz

If it does not work, you can try change the JAVA_HOME in /etc/enviroment file

Append JAVA_HOME="${/.../JVM_PATH}"

For example:

JAVA_HOME="/usr/lib/jvm/java-7-openjdk-amd64"

and then reload this file:

$ source /etc/environment

Source: link

pablopatarca
  • 624
  • 6
  • 10
3

This seems like permission problem. Someone who packed Android Studio, has the original files under non-root account. If you unpack it as root, the files and dirs has no permission for "other" (just for owner). The person who is packing Android Studio knows a lot about Android and Java, but not much about Unix permissions (uch!). There are two possible solutions:

a) unpack android-studio-bundle-...-linux.tgz as normal user, not as root (this has an advantage - you will be able to update Andriod Studio by clicking menu; but this is generally stupid because you are open to malware attack)

b) fix read permissions for files and dirs for whole android-studio directory with something like: chmod -R +r /opt/android-studio

red-goblin
  • 41
  • 3
Milan Kerslager
  • 404
  • 2
  • 6
2

for openjdk: export JAVA_HOME=/usr/lib/jvm/default-java

but you would better use the oracle jre to run android studio

Jarod
  • 1,662
  • 1
  • 11
  • 19
2

I solved this by installing the jdk. This sounds annoyingly simple but I missed it. I thought I Had installed the jdk, but I had actually installed the jre.

Wrong:

sudo apt-get install openjdk-7-jre

Right:

sudo apt-get install openjdk-7-jdk

As soon as I did that, it started up fine for me. The things we miss sometimes....

EliT
  • 75
  • 8
1

Although I have JDK installed and was pointing to it, i didn't have java-1.7.0-openjdk-devel installed (Fedora).

David
  • 51
  • 3
  • I am using Fedora 20 and this was my issue also. Once I install the devel package and had my environment variable set, Android Studio fired right up! Thank you. – AgnosticDev Nov 09 '14 at 14:47
0

This is what I did to solve the problem:

cd /opt/ (where android-studio directory is located)

sudo chown -R your_user:your_user android-studio

(where your_user is... yes your username :) )

0

the solution for me was to modify studio.sh and add JAVA_HOME as a variable:

# ---------------------------------------------------------------------
# Locate a JDK installation directory which will be used to run the IDE.
# Try (in order): STUDIO_JDK, ../jre, JDK_HOME, JAVA_HOME, "java" in PATH.
# -------------------------------------------------------------------

     JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-i386/

if [ -n "$STUDIO_JDK" -a -x "$STUDIO_JDK/bin/java" ]; then (etc..)
0

This below trick work for me , Check your app dependencies in build.gradle(Project:AppName) .

Try the latest build.gradle version.

classpath 'com.android.tools.build:gradle:2.2.1'

Piash Sarker
  • 103
  • 1
  • 6
0

You have to have the latest JDK. I solved it by
   sudo apt-get install openjdk-8-jdk
(Note the '8' in there)