Please help - Spawn java application from PHP

Status
Not open for further replies.

Silver-0-surfer

Well-Known Member
Joined
Jan 5, 2008
Messages
317
Reaction score
7
Location
CPT
Hi

So I made a java app that will create a PDF for me based on some criteria that gets passed to it via the CLI.

so normally i run

java pdf_create some random info here

and this creates a PDF for me. What I need to do is be able to call that from a webpage, running PHP.

I have tried EVERYTHING,!

exec('java pdf_create some random info here');
passthu('java pdf_create some random info here');
echo `java pdf_create some random info here`;
system('java pdf_create some random info here');

but none of it works. Is it possible to do this? I have set the permissions on the file to 777 but still no luck.
 
You need to use the absolute path of the java app in the exec.

In the command line/terminal run "which java" to get the path. It will return something like "/usr/bin/java". If you do not have access to the server, then you can also run the command from exec.

Just understand that exec will wait until the java app has finished so set the script timeout to longer or else run it in the background with an "&" at the end of script.

eg exec("/usr/bin/java /home/usr/my-java-code&")
 
If all you want, is to create a PDF from input criteria in PHP, have a look at http://www.fpdf.org

It works very well and I have used it on one of my websites to generate a PDF quotation from an input form.
Let me know if you want me to post a link where you can see it in operation.
 
Status
Not open for further replies.
Top
Sign up to the MyBroadband newsletter
X