What are the advantages and disadvantages of using system calls or shell commands to interact between Java and PHP?

When interacting between Java and PHP, using system calls or shell commands can be a quick and efficient way to pass data or execute commands between the two languages. However, this approach can introduce security vulnerabilities and may not be the most reliable method for communication.

// Example of using shell_exec to execute a Java program and capture the output
$output = shell_exec('java -jar HelloWorld.jar');
echo $output;