Android Studio and Java JDK

Trying to get Android Studio to start but I’m getting an error saying JAVA_HOME points to a jre not a jdk, and can’t find tools.jar

java -version

openjdk version “1.8.0_77”
OpenJDK Runtime Environment (build 1.8.0_77-b03)
OpenJDK 64-Bit Server VM (build 25.77-b03, mixed mode)

I installed java-1_8_0-openjdk-devel also, but I’m not sure how to change JAVA_HOME to point to the jdk, and not the jre.

/usr/lib64/jvm is full of java folders, which just adds to the confusion:

java                      java-1.8.0-openjdk        jre                jre-openjdk
java-1.7.0-openjdk-1.7.0  java-1.8.0-openjdk-1.8.0  jre-1.8.0
java-1.8.0                java-openjdk              jre-1.8.0-openjdk

Which one, and how to I set JAVA_HOME to it?

I wrote a script to start it and export the path;

cat ~/bin/android_studio 

export JAVA_HOME="/etc/alternatives/java_sdk_openjdk"
cd ~/data/android/android-studio/bin && exec ./ $*
export JAVA_HOME="/usr/lib64/jvm/jre"

You will need to adjust the path to

I also created a desktop (aka menu/shortcut item;

cat .local/share/applications/android.desktop

#!/usr/bin/env xdg-open
[Desktop Entry]
Name=Android Studio
Comment=Android Studio integration environment tool

Again, adjust the Icon path for your setup, you may need to use the full path in Icon and Exec.

Thanks, I didn’t know about the alternatives directory. I’ll give this a try, just as a side question, why would you need to change the JAVA_HOME back to the jre? I thought the JDK contains the jre AND the dev tools, so having JAVA_HOME point to the jdk would still allow applications like libreoffice to run properly?

Yes, I just wanted it back at where I originally started after finishing the testing, try a complete switch and see what happens, if it all works fine it can be removed and placed in your ~/.profile. My preference is per user rather than system wide…

If you’re using openjdk, despite the name it only is the jre.
The error is saying that you don’t have the “jdk” components installed which means that you need to first identify the “openjdk-devel” packages available to you with the following

zypper se openjdk-devel

Today, the above will likely return two results, one for openjdk-devel version 7 and the other for version 8.
Install either or both packages displayed

zypper in* package1 package2* 

In openjdk’s case, when you install the “devel” packages, they will automatically link to and extend the functionality of your existing “update-alternatives” options, so you won’t see anything different than without the “devel” packages installed. But, you are now ready to select whichever java package you wish if you have multiple java installed (like Oracle Java or different versions of openjdk). When integrated with “update-alternatives” your selected Java should also automatically set the “HOME” environmental variable, no need to set on your own.

update-alternatives --config java

If you did the above, you shouldn’t have a problem.