0

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

Jerry Abraham
  • 103
  • 12
  • 1
    Is `Java.inc` in the PHP language? Does it define a class for `Javav`? – GetSet Apr 15 '20 at 17:11
  • @GetSet yes there was no such function but now I checked there is Java function so changed the function name now but gives another error – Jerry Abraham Apr 15 '20 at 17:26
  • Javabridge is a network based protocol, you can't just include the jar... you need a server (with jar's you need), There's a standalone version, but I suggest to have a look to https://belgattitude.github.io/soluble-japha/ first. It's a reworked version of the javabridge... – Sébastien Vanvelthem Apr 16 '20 at 07:30

0 Answers0