Detect if java is installed on a web server with php

Is it possible to detect from php script if java is installed on the server (if I can run the exec () command using java)?

Thank,

Benjamin

+3
source share
2 answers

Well, if you can run exec, you can use cli detection of your choice, for example which java, locate javaetc. I am sure there are many ways to do this (the two I presented are not necessarily the best).

+2
source

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');
+1
source

Source: https://habr.com/ru/post/1731427/


All Articles