enhance scripts to work on Debian-like machines

On Debian-like machines, `$(which java)` is always `/usr/bin/java.`.

`readlink -f` unpicks this through the alternatives system into e.g. `/usr/lib/jvm/java-8-oracle/jre/bin/java`.

And, have to use `javac`, not `java`, to remove the `/jre/` from the path.