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.

2
  • 1
    possible duplicate of Error to run Android Studio
    – Caleb
    Commented Jul 24, 2013 at 7:51
  • Hi there can you please accept my awnser if it helped you, tx :)
    – Francois
    Commented Jul 24, 2013 at 17:46

11 Answers 11

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
3
  • 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! Commented Mar 21, 2014 at 21:36
  • 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. Commented Jan 12, 2016 at 14:47
  • 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!
    – Eddy
    Commented Mar 2, 2017 at 20:22
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

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. Commented May 11, 2014 at 21:29
  • 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.
    – six-k
    Commented Mar 13, 2015 at 20:11
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.

0
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

1
  • 2
    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?
    – pasx
    Commented Apr 10, 2016 at 5:16
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
1
  • 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-devel Commented Jan 7, 2016 at 19:06
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.

2

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

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

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.

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/
0

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.