I have two files, index.php and foo.java. In foo.java I have the class bar with the function foobar.
Now I want to create object baz in my index.php of the class bar and make it run function foobar. I know PHP and Java don't speak the same language, but I can use JSON to create an java object and have it call the function? If so, how?
You can use shell_exec
and run java from CLI.
<?php
$output = shell_exec('java [MyPackage.]MyClass MY_METHOD');
echo "<pre>$output</pre>";
?>