I'm trying to run a Java program from a PHP page, using the function shell_exec(), the problem is that always return an empty response. When run a command like: ls, whoami, which, it works. I think that is related to grant access for the www-data user, but I still can not find a way to do it.
I tried to modify the file /etc/sudoers with the command sudo visudo, for add to the end of the file the next line that suppose to grant access for execute the java command:
www-data ALL=NOPASSWD: /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
and tried with this too:
www-data ALL=NOPASSWD: /usr/bin/java
I'm using next code to invoke the java command from the php page:
$result = shell_exec('java -version');
echo $result;
I expect the output of the invoked command, but the actual output is empty.
thanks in advance.