Can't execute a Java App from PHP

davecoventry's picture

He has: 112 posts

Joined: Jun 2009

I'm trying to run a Java App from PHP.

system('java -jar /home/dave/web/drupal/java/dist/emp.jar'); fails. nothing prints out, it just returns FALSE.

However, this works:
system('java -jar');

Prints out the help info normally associated with incorrect parameters passed to Java.

This also works:
system("ls -l /home/dave/web/drupal/java/dist/emp.jar");

Prints out a listing of /home/dave/web/drupal/java/dist/emp.jar including permissions.

This has got me foxed. Can anyone suggest anything to try?

The Jar was built using NetBeans and it runs fine from the commend line.

I have posted this on Daniweb.com, too, but nothing from there just yet...

They have: 121 posts

Joined: Dec 2008

The execution of the jar file itself may be failing...

I assume the jar file executes fine when you try to run it from the command line. If it does...

The web service user executing the PHP script may be missing CLASSPATH environment variable values to the libraries you are using. Make sure those are set / present in your PHP script before execution.

Cheers,
Shaggy.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.