How to run JAR file using php script?

510 Views Asked by At

I tried JAVA bridge to get output from my jar file followed this https://stackoverflow.com/a/10253798/1870048, I am using XAMP Server and from that Apache and Tomcat server is been used

  require_once("http://localhost:8080/JavaBridge/java/Java.inc");     
  $cartObj = Java("Cart"); //Javav("Cart");
  $cartObj->Cart("098765");
  $cartObj->setLang("EN");
  echo  $cartObj->getLang();

but gives error : Fatal error: Call to undefined function Javav() What should I exactly I look into?

Also I tried below way also to call the jar file by placing the jar file in my zampp htdoc folder: (D:\xampp\htdocs\jar)

//  Using shell_exec
exec('java -jar AutoDiscounts.jar '.$jsonRequest.' 2>&1', $result);
print_r($result);

//  Using shell_exec
$arg1 = $jsonRequest;//"My_INPUT_PARAMETER";
$output = '';
$output =shell_exec("java -jar AutoDiscounts.jar $arg1");
echo "Done calling shell exec:";
echo $output;

But both above cases does not give any output .Basically my jar will do some cart processing and return output and it works in the JDevloper

enter image description here

0

There are 0 best solutions below