开发者

how should i run a java program from a php page,on submitting a form?

开发者 https://www.devze.com 2023-03-25 16:50 出处:网络
i ve a .php page and now i want to run a java program in the backend after submitting a form in php.i ve tried using exec(), system() functions and sadly its not working. please help me out.

i ve a .php page and now i want to run a java program in the backend after submitting a form in php.i ve tried using exec(), system() functions and sadly its not working. please help me out. This is the code snippet:

if($_POST["ADD"])
{
        echo "Phrase has been added now"."<br />";
        $lastline=exec("java -Dwordnet.database.dir=D:\wordnet\2.1\dict Process",$retval); 
}

Process is my main class which I want to be execu开发者_C百科ted.


First, you posting an error message would have been helpful. Checking the return code is also wise.

Second, specify the full path to java, e.g. /usr/bin/java instead of just using java.


Start the java process in debug mode i.e. with jdwp enabled. Then connect to the java process with some debugger for example jdb but better use full fledged IDE like Eclipse. Make sure you set suspend flag to y otherwise the java process will terminate before you are able to establish debug session to it

exec("java -Xrunjdwp:transport=dt_socket,address=9002,server=y,suspend=y <the rest of command>")

A somewhat simple solution is to use logging in you java app, configured to write to some file, so that you can check whats going wrong during execution.

Btw, are you sure that the java program is actually getting executed? :)

0

精彩评论

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