I install groovy in ubuntu and when i run groovy command in terminal i saw the bellowing error:
groovy: JAVA_HOME is not defined correctly, can
not execute: /usr/local/java/jdk1.8.0_20/bin/java
what should i do to solve this?
I install groovy in ubuntu and when i run groovy command in terminal i saw the bellowing error:
groovy: JAVA_HOME is not defined correctly, can
not execute: /usr/local/java/jdk1.8.0_20/bin/java
what should i do to solve this?
Updating JAVA_HOME
or PATH
environment variables is ok for individual users, but to fix it system-wide, just create the missing symlink. For me, it went like this:
$ groovy --version
groovy: JAVA_HOME not defined, can't execute: /usr/lib/jvm/default-java/bin/java
$ cd /usr/lib/jvm
$ ls -log
lrwxrwxrwx 1 20 Nov 1 14:17 java-1.8.0-openjdk-amd64 -> java-8-openjdk-amd64
drwxr-xr-x 7 4096 Feb 3 02:36 java-8-openjdk-amd64
$ sudo ln -s java-8-openjdk-amd64/ default-java
$ groovy --version
Groovy Version: 2.4.8 JVM: 1.8.0_151 Vendor: Oracle Corporation OS: Linux
You should take the whole directory where java is installed and also add java home in PATH variable, for example:
export JAVA_HOME=/usr/java/jdk1.8.0_31
export PATH=$JAVA_HOME/bin:$PATH
For verification purpose you can also run below commands,
echo $PATH
java -version