Ask Your Question

Setting $JAVA_HOME on new install for Android Studio

asked 2015-07-13 15:29:44 -0500

jstock23 gravatar image

updated 2015-07-13 22:59:05 -0500

I'm currently setting up Android Studio on a new F22 install.

When trying to run the launch script I'm getting this message:

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

I've tried setting JAVA_HOME to /etc/alternatives/jre_1.8.0_openjdk which I found by searching, but that hasn't worked. I know the install comes with openjdk, or maybe just jre, and also that it's headless. I've run "sudo dnf install java" which I think got the rest, but I'm not sure where that was installed to, or whether it comes with a JDK.

Edit: I've tried all the possible paths that were already in /usr/lib/jvm, but with no luck. I downloaded the Oracle JDK, both the x86 version and the 64 version and those don't seem to work either, even though they certainly do have tools.jar. I'm still getting the same error message as before.

edit retag flag offensive close merge delete


If you are running the application via GUI/icon, then you have to exit and login again. If executing from a terminal, then export the variable and launch the executable.

NuuN gravatar imageNuuN ( 2015-07-14 00:21:28 -0500 )edit

Have you tried launching from a terminal with the JAVA_HOME set and exported?

NuuN gravatar imageNuuN ( 2015-07-14 11:31:57 -0500 )edit

I updated my answer. Hopefully it will solve your problem.

Bill Chatfield gravatar imageBill Chatfield ( 2015-07-19 14:14:54 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted

answered 2015-07-13 17:32:08 -0500

updated 2015-07-19 09:47:02 -0500

I have it working with no environment variables set and I set "alternatives" to the Oracle JDK. OpenJDK works as well, but Android recommends Oracle.

So, I would suggest that you make sure JAVA_HOME, JDK_HOME, and JRE_HOME are not set. Then use the alternatives command to make the Oracle JDK the default java. Android Studio will figure it out without the environment variables.

Unset java variables for a particular session:

unset JDK_HOME
unset JRE_HOME

To unset them permanently, take them out of ~/.bash_profile, ~/.bashrc, or where ever you put them.

Do this once to set the current version of java, choosing the Oracle JDK in /usr/java:

[bill@billslaptop bin]$ alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
*  1           /usr/lib/jvm/java-1.8.0-openjdk-
 + 2           /usr/java/jdk1.8.0_45/jre/bin/java

Enter to keep the current selection[+], or type selection number: 

Old Answer:

Put this in your ~/.bash_profile and then log out and back in again:

export JAVA_HOME=/usr/lib/jvm/java

The JDKs are in /usr/lib/jvm.

edit flag offensive delete link more


If that does not work, drop it into _~/.bashrc_. Systemd-user does not work with .bash_profile by default.

NuuN gravatar imageNuuN ( 2015-07-13 17:36:51 -0500 )edit

lib! Of course! Thanks.

jstock23 gravatar imagejstock23 ( 2015-07-13 22:12:57 -0500 )edit

Awesome find! On other distros, each problem package has there own configuration tool. Good to know this has a method too!

NuuN gravatar imageNuuN ( 2015-07-19 15:35:25 -0500 )edit

Thanks for the update. That seems to make a lot of sense. I decided to download the SDK to my internal HD devoted to my /home folder. That way I can upgrade the OS by doing a fresh install on my SSD and then just reconnect everything. So I don't have to re-download the SDK etc.

I'll mark it as answered because that seems to be good.

jstock23 gravatar imagejstock23 ( 2015-07-20 10:20:32 -0500 )edit

answered 2015-11-17 04:51:53 -0500

pguth gravatar image

Just install the *-devel package of OpenJDK:

sudo dnf install java-1.8.0-openjdk-devel

edit flag offensive delete link more


I confirm it. The devel package contains tools.jar and makes Android Studio work. No need to install Oracle JDK.

proski gravatar imageproski ( 2016-02-06 20:53:38 -0500 )edit

Second confirmation. Just did it then. No mess, no fuss.

HologramOfMe gravatar imageHologramOfMe ( 2016-02-08 15:11:43 -0500 )edit

3rd confirmation. easy peasy

tkjef gravatar imagetkjef ( 2016-03-02 20:21:42 -0500 )edit

This should be the accepted answer.

Bart Friederichs gravatar imageBart Friederichs ( 2016-06-15 04:01:09 -0500 )edit

I confirm this works for me too.

WolfangAukang gravatar imageWolfangAukang ( 2016-07-04 23:00:43 -0500 )edit

answered 2015-07-13 17:26:49 -0500

NuuN gravatar image

This Arch wiki on Java exports the path from somewhere in _/usr/lib/jvm_. So you would export JAVA_HOME=/usr/lib/jvm/<path to your preferred JDK>.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2015-07-13 15:29:44 -0500

Seen: 12,931 times

Last updated: Jul 19 '15