0

I wrote a java class with name GetRandomKey.class

I run this file with this command:

<?php
    echo shell_exec('java GetRandomKey');
?>

This code is run in local (Windows 10 - 64bit)

But I upload in VPS with Windows server 2016 and 64bit.

It doesn't work and it returns an empty result!

I wrote this code shell_exec('dir') and its return result. but I can't run java command.

I get this Error!

C:\Program Files\Java\jre1.8.0_202\lib\amd64\jvm.cfg

ABP
  • 692
  • 4
  • 21
  • make sure java is installed on server and permission is allowed to execute commands form php – Jatin Parmar Mar 29 '19 at 13:01
  • 1
    Possible duplicate of [PHP detect if shell\_exec() command failed](https://stackoverflow.com/questions/7923876/php-detect-if-shell-exec-command-failed) – insertusernamehere Mar 29 '19 at 13:01
  • I install Java. I can run this command in CMD and get the result. but in PHP I can't. – ABP Mar 29 '19 at 13:02
  • I can run this command and get result: shell_exec('dir') – ABP Mar 29 '19 at 13:03
  • use: `exec("java GetRandomKey 2>&1", $msg);` and then `var_dump($msg)` to show possible errors. – jibsteroos Mar 29 '19 at 13:15
  • @jibsteroos I get this Error: Error: could not open `C:\Program Files\Java\jre1.8.0_202\lib\amd64\jvm.cfg – ABP Mar 29 '19 at 13:21
  • this might help [running-java-gives-error-could-not-open](https://stackoverflow.com/questions/6036462/running-java-gives-error-could-not-open-c-program-files-java-jre6-lib-amd64) – jibsteroos Mar 29 '19 at 13:24
  • @jibsteroos No. it doesn't help! – ABP Mar 29 '19 at 13:45

0 Answers0