I have tried and looked at the past Gradle Java_HOME questions, however none of the options seems to work. I followed this website to install Gradle. However, all the Gradle commands I run result in the following error:
ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/jdk1.8.0_241
Please set the JAVA_HOME variable in your environment to match the location of your Java installation.I'm also using OpenJDK 11 and
$ echo $JAVA_HOME
/usr/lib/jvm/jdk1.8.0_241 4 1 Answer
You can find java home by using the following command:
java -XshowSettings:properties -version 2>&1 > /dev/null | grep 'java.home' It will print something like:
java.home = /path/to/java_homeYou can set the output of this command as JAVA_HOME by copying the path and adding the following line to your ~/.bashrc.
export JAVA_HOME=/path/to/java_home