Make PHP execute and communicate with a Java application on a web server

前端 未结 4 1913
你的背包
你的背包 2021-01-12 09:10

I have a java application that will take the image as an input and output another image. I have a website with a popular host (PHP+MYSQL Hosting). I want to create a page on

4条回答
  •  既然无缘
    2021-01-12 10:13

    Now my questions are: Is it possible to execute java apps on popular webhosts (for example mine is WebHostingBuzz.com)?

    It's technically possible. But the hosting has to install JRE at the host and give the PHP user sufficient OS-level and filesystem-level permissions. So you're really dependent on the hosting whether they provide this opportunity. Best is to just contact their support team and ask it.

    If it is supported, you could just use shell_exec().

    $result = shell_exec("java -jar /path/to/imageprocessor.jar " + $imagepath);
    if ($result) {
        // Shell execution succeed.
    } else {
        // Shell execution failed.
    }
    

    For asynchronous communication / background processing, the client has to fire an ajaxical request.

    If it is not supported, consider porting Java to PHP. The GD image library has pretty a lot of functions which may be of use.

提交回复
热议问题