Integrating PHP and Java?
I'm looking to write a web service that can take on Java code input by the user and compile and show the results back. Is there any recommended platform that will let me do this using PHP - so that I can integrate java functionality into it? I need a text area for code that can be compiled.
Also, what kind o开发者_开发百科f server considerations would this require? I'm assuming I'd need a JVM running on my server. Please feel free to ask follow up questions.
Cheers.
You could either compile the code using the java compiler like any other binary using exec() system() or similar, then execute it and read the output.
Another solution would be to execute the java code using one of these two products:
http://www.zend.com/en/products/server-ce/
http://php-java-bridge.sourceforge.net/pjb/
But that would probably take more work. And by the way, look out for malicious programs by running the executable in a safe environment, preferrably under some other user than the web server is running under. You could and should also use the java sandbox functionality to disable dangerous functions (like IO etc).
精彩评论