4

I have just downloaded the Android Studio and when I try to run ./studio.sh it gives me an error of

'tools.jar' seems to be not in Android Studio classpath. Please ensure JAVA_HOME points to JDK rather than JRE

I have checked /usr/lib/jvm/java-1.7.0-openjdk-amd64 this folder java is there and I have set the environment variables in

/etc/environment

as

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

but still, the same error is coming, Please help me out,

after saving this file, if I check

echo $JAVA_HOME

nothing comes and when I try

source /etc/environment

it comes as

JAVA_HOME: command not found

How should I proceed?

A.B.
  • 89,123
  • 21
  • 245
  • 323
Amul Bhatia
  • 358
  • 2
  • 6
  • 13
  • try this link: [How to setup Java-Home and Path in Ubuntu 12.04](http://askubuntu.com/questions/321422/how-to-setup-java-home-and-path-in-ubuntu-12-04) – Lety Jul 06 '14 at 15:33
  • still same error is coming, i have downloaded the Java version again from oracle webiste as suggested on the link, and install it and moved to lib/jvm, but same error. echo $JAVA_HOME is giving nothing.again.. – Amul Bhatia Jul 06 '14 at 19:14
  • did you add PATH=$PATH:$JAVA_HOME/bin? could you post your /etc/environment file? – Lety Jul 06 '14 at 19:51
  • Seems you install only **JRE**. Visit related **[question](http://askubuntu.com/q/122133/181228)**. – Anton Dozortsev Jul 06 '14 at 20:55

4 Answers4

9

I got the same error when trying to run the android-studio beta installation. I tried various options, but the one that worked for me was:

sudo apt-get install openjdk-7-jdk 

Didn't have to do anything else.

But, I am surprised that

java -version  

listed the same 3 lines before and after the jdk install:

java version "1.7.0_55"  
OpenJDK Runtime Environment (IcedTea 2.4.7) (7u55-2.4.7-1ubuntu1~0.13.10.1)  
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)

and

echo $JAVA_HOME

outputs blanks, but now the android-studio is running.

A.B.
  • 89,123
  • 21
  • 245
  • 323
Sri
  • 1,572
  • 2
  • 19
  • 38
2

Check the most liked answer. If java is already installed and want to change the priority then

update-alternatives --config java
OmaL
  • 261
  • 3
  • 8
0

For me there was a problem with some certificates (seems to be a java bug).
I fixed it with the following (reference):

$ sudo dpkg --purge --force-depends ca-certificates-java
$ sudo apt-get install ca-certificates-java
L31N
  • 51
  • 1
  • 5
0

I had a similar problem and I performed:

sudo apt-get install oracle-java8-set-default

Hope it helps!

MadMike
  • 4,234
  • 8
  • 28
  • 50
Micke
  • 1