How does one detect if java is installed without triggering a visual prompt?
rtrouton has some great examples on his derflounder website.  The examples are used as extension attributes in a mdm suite, just remove the results tags from them.  Below is a script that looks for the java install folder, if it exists echo out the version if not echo not installed.  This in return never triggers the java command keeping the pop up away.

if [[ -e /Library/Java/Home ]]; then
    echo "$(java -version 2&gt;&amp;1 | awk '/version/{print $3}' | sed 's/"//g')"
        else
    echo "Java not installed"
fi