I am currently in the process of installing Gradle and JAVA on my computer, which I recently upgraded to 19.04. Gradle is reporting that the $JAVA_HOME is incorrect.
I started out by following these instructions to install java https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-on-ubuntu-18-04 I also referred to exercism’s instructions for installing java and gradle, though they appear to be out of date. https://exercism.io/tracks/java/installation#linux
sudo apt install default-jdk and then set $JAVA_HOME in
~/.bash_profile, like so:
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64 Next, I installed gradle with apt,
sudo apt install gradle. I also updated the PATH with
When I ran
gradle test in my project, it gave me this error.
ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/java-11-openjdk-amd64/bin/. I found this stack overflow error that suggested it could be a problem with the gradle install from apt. https://stackoverflow.com/questions/22307516/gradle-finds-wrong-java-home-even-though-its-correctly-set I then uninstalled the gradle install from apt using
sudo apt-get purge --auto-remove gradle and decided to follow gradle documentation.
Referring to https://gradle.org/install/, I downloaded the binary and unzipped it in
/opt/gradle. I then added gradle to my PATH variable.
Then I tried running
gradle test and got the same error again.
ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/java-11-openjdk-amd64/bin/
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
How can I install gradle on ubuntu 19.04 and get around this error?