"Please ensure you have JAVA_HOME points to JDK rather than JRE" message

71,844

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:
71,844
Alex Malex
Author by

Alex Malex

Updated on September 18, 2022

Comments

  • Alex Malex
    Alex Malex over 1 year

    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

    JAVA_HOME=/usr/local/java/jdk1.7.0_17
    PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
    JRE_HOME=/usr/local/java/jre1.7.0_17
    PATH=$PATH:$HOME/bin:$JRE_HOME/bin
    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?

    update

    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"
    
    • Alex Malex
      Alex Malex almost 11 years
      echo java_home gives me /usr/local/java/jdk1.7.0_17
    • Sajesh Kumar
      Sajesh Kumar almost 11 years
      You should have .jinfo files, but I have updated my answer to set the update alternatives without them.
  • Alex Malex
    Alex Malex almost 11 years
    java version "1.7.0_17" but I didn't do what you suggested me. do I need it?
  • Alex Malex
    Alex Malex almost 11 years
    which java -- /usr/bin/java
  • Alex Malex
    Alex Malex almost 11 years
    I updated my topic4
  • Alex Malex
    Alex Malex almost 11 years
    I mean, I cannot launch it. ls /usr/lib/jvm/.*.jinfo -- No such file or directory
  • Sajesh Kumar
    Sajesh Kumar almost 11 years
    try sudo updatedb and when it's done locate *.jinfo
  • Sajesh Kumar
    Sajesh Kumar almost 11 years
    doesn't give you any output?
  • Sajesh Kumar
    Sajesh Kumar over 8 years
    @DmitryShvedov Please have a look at askubuntu.com/questions/388593/setup-jdk-for-android-studio (most likely the version numbers are now different)