Using php extension to run java command

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
puritys
Forum Newbie
Posts: 2
Joined: Thu May 24, 2012 4:21 am

Using php extension to run java command

Post by puritys »

First I try php code to run java.
=== php ===
<?php
exec("java -cp xx.jar xxxxx");
?>

Nothing response when I run it from browser.

Then I write php extension (c++) .
===c++ ===
string c_java(){
return system("/usr/bin/java -cp xxx/javase/javase.jar xxxxxxxxxxxxx");
}

Nothing response too. Why I can't use php extension to run java command ?.
any one knows that?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Using php extension to run java command

Post by Christopher »

You should look at the different execution functions. The exec() function does not return much of the output, but does have some parameters that do. Other funcitons like passthru() will show more output in the browser.
(#10850)
puritys
Forum Newbie
Posts: 2
Joined: Thu May 24, 2012 4:21 am

Re: Using php extension to run java command

Post by puritys »

When I run that php code from linux command line , I can get the right response.
If request come from browser , It will return nothing.

-----program flow -------
Browser -> request apahce -> php -> php extension -> c++ -> call java -> java virtual machine , this flow happen some error .
I guess java virtual machine can't be executed in apache thread.
Post Reply