Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have java installed

aaa@ubuntu:~$ whereis java
java: /usr/bin/java /usr/bin/X11/java /usr/local/java /usr/share/java
aaa@ubuntu:~$ whereis javac
javac: /usr/bin/javac /usr/bin/X11/javac

and etc/profile

export JAVA_HOME
export JRE_HOME
export PATH

However, when I run Android Studio, it says:

tools.jar in not in Android Studio classpath. Please ensure you have JAVA_HOME points 
to JDK rather than JRE.

How do I fix it?


sudo update-alternatives --get-selections | grep ^java 
java                           manual   /usr/local/java/jre1.7.0_17/bin/java
javac                          manual   /usr/local/java/jdk1.7.0_17/bin/javac
javaws                         manual   /usr/local/java/jre1.7.0_17/bin/javaws

java -version
java version "1.7.0_17"
share|improve this question
echo java_home gives me /usr/local/java/jdk1.7.0_17 – Alex Malex May 17 '13 at 13:54
You should have .jinfo files, but I have updated my answer to set the update alternatives without them. – Gerhard Burger May 21 '13 at 7:47
up vote 8 down vote accepted

You have to use the jre version in the jdk, you can do so by executing

    sudo update-alternatives --set java /usr/local/java/jdk1.7.0_17/jre/bin/java
    sudo update-alternatives --set javaws /usr/local/java/jdk1.7.0_17/jre/bin/javaws

Normally this can be done by using update-java-alternatives with a .jinfo file, but for some reason you can't find them on your system.

share|improve this answer
java version "1.7.0_17" but I didn't do what you suggested me. do I need it? – Alex Malex May 17 '13 at 14:23
which java -- /usr/bin/java – Alex Malex May 17 '13 at 14:24
I updated my topic4 – Alex Malex May 17 '13 at 15:51
I mean, I cannot launch it. ls /usr/lib/jvm/.*.jinfo -- No such file or directory – Alex Malex May 18 '13 at 4:19
try sudo updatedb and when it's done locate *.jinfo – Gerhard Burger May 18 '13 at 19:52

protected by Community Jul 28 '15 at 19:19

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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