开发者

Integrating PHP and Java?

开发者 https://www.devze.com 2023-01-24 10:10 出处:网络
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

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).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号