0

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?

2

1 Answer 1

3

You can use shell_exec and run java from CLI.

<?php
$output = shell_exec('java [MyPackage.]MyClass MY_METHOD');
echo "<pre>$output</pre>";
?>
Sign up to request clarification or add additional context in comments.

1 Comment

You will need to return json output here. Are you getting output here?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.