Ca not run Java code with script

I am running Atom on Ubuntu 20 and would like to run Java code with script. I can do that, but I get the following error:

$JAVA_HOME and $PATH to Java home directory is set.

Any ideas?
Thanks.