One of the following situations apply to you:
Problem scenario #1
You try to run a Groovy command (e.g., groovy foobar.groovy), but you get this error:
"groovy: JAVA_HOME is not defined correctly, can not execute: /usr/lib/jvm/java-9-openjdk/bin/java"
Problem scenario #2
You get this error when you run an "hdfs" command:
ERROR: /usr/bin//bin/java is not executable.
What should you do?
Solution
- Set the JAVA_HOME variable. Run this command: which java
- Mentally eliminate the trailing "/bin/java" from the above command. If Java was not found, follow these directions to install Java.
- Draft this command but replace "foobar" with the results of step #2 (with the elimination of "/bin/java" from the end of step #1's results): export JAVA_HOME=foobar
- Run the drafted command from above.
- Try to use Groovy again.
If you want the solution to persist a reboot, we recommend rebooting the server and seeing if your original problem is reproducible. Then run a command like this but replace "foobar" with the results of step #2 (with the elimination of "/bin/java" from the end of step #1's results):
echo 'export JAVA_HOME=/foobar' >> ~/.bashrc