Compruebe si un archivo Java se compiló correctamente usando PHP
Frecuentes
Visto 316 veces
0
So I need to check out the output of a Java program I am compiling and running using PHP:
$output = shell_exec('cd write && javac JavaCode.java && java JavaCode');
I don't get anything written to the $output string if the javac command fails. So how do I perform these operations and checks using PHP?
3 Respuestas
1
Deberías estar recibiendo NULL
returned if there was an error.
The output from the executed command or NULL if an error occurred or the command produces no output.
Intente var_dump($output)
and see what it returns
respondido 27 nov., 13:01
0
anexar && echo 'message'
at the end. Since it's an and, you won't get the message back if any of the commands fail
so
$output = shell_exec('cd write && javac JavaCode.java && java JavaCode && echo \'success\'');
respondido 27 nov., 13:01
0
exec
can give you return value:
exec('cd write && javac JavaCode.java', $output, $returnValue);
if ($returnValue == 0) {
echo 'success';
} else {
echo 'compilation failed';
}
respondido 27 nov., 13:02
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas java php shell shell-exec or haz tu propia pregunta.