1

I have made a custom java program to output a license and am trying to run it in php.

$deviceid="12345";
$command_app = 'java -jar /home/myname/secure/mycommand.jar ';
$privateKey = 'QEFAASCAmEwggJdAgE';
$command_app_args = "\"$privateKey\" deviceid=$deviceid";
$command=$command_app.$command_app_args;
$license = shell_exec($command);

The problem is that $license is empty every time, I tried to print out the $command using

echo $command;

and then ran that command directly in the linux terminal and the xml output was correct.

I am using

System.out.println() 

in the java app to print all the xml output. I tried something simple like

shell_exec('ls -l') ;

and sure enough if worked.

What might I be doing wrong?

1
  • What do you get for which java? Commented Jun 9, 2010 at 15:23

1 Answer 1

2

My first instinct is that the command java is not in PHP's shell path. Try something like this:

$command_app = '`which java` -jar /home/myname/secure/mycommand.jar ';

The command which java will return the full path to the java executable...

Sign up to request clarification or add additional context in comments.

3 Comments

$java = which java; echo $java; produced nothing, however $java = ls -l; echo $java; worked
which ls produced /bin/ls so for some reason php can't locate java even with the which command
I used the full path /usr/java/jdk1.6.0/bin/java in the php command instead of java and it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.