I used this:
$result = exec('command -v java >/dev/null && echo "yes" || echo "no"');
$resultshould be yesif a java command exists or noif it is not. If you are running Windows, you need another command. Maybe something like:
$result = exec('java -version > NUL && echo yes || echo no');
source
share