We need to call a user defined java function within php code,so javaBridge connection is needed.
we have done the php-javabridge-configuration and it is working fine. http://phprambabu.blogspot.in/2016/04/php-javabridge-configuration.html
To connect php with java class, we are running the java class from eclipse on tomcat server, HTTP port:8086 and mentioning the same port number in java.inc file, and its path is added in php file as "required_once(Java.inc)".
-> this shows error in Java.inc file but changes made in Java.inc seems correct according to other resources found on internet and stackoverflow.
changes in Java.inc
define ("JAVA_HOSTS", "localhost:8086");
...
if(!defined("JAVA_HOSTS")) {
if(!java_defineHostFromInitialQuery(java_get_base())) {
if ($java_ini=get_cfg_var("java.hosts")) define("JAVA_HOSTS",$java_ini);
else define("JAVA_HOSTS","127.0.0.1:8086");
}
}
php file content snippet
function createBridge() {
$demo = new java("main.bridge");
echo 'New Bridge instance created';
$demo->fn();
return $demo;
}
Here, running java src folder contains -> "main" folder contains -> "bridge.java" -> fn() function
if mentioned changes are done in java.inc, Fatal error occurs:
Fatal error: HTTP status 403, Access to the specified resource has been forbidden. Apache Tomcat/7.0.72 in C:\xampp\htdocs\JavaBridge\java\Java.inc on line 869
Line 869 refers to 3rd line of below snippet:
function dieWithBrokenConnection($msg) {
unset($this->protocol->client->protocol);
trigger_error ($msg?$msg:"unknown error: please see back end log for details",E_USER_ERROR);
}
And we are using Xampp for local server. Please let us know if I'm doing something wrong in between or any other useful stuff that can help us out.
function dieWithBrokenConnection($msg) { unset($this->protocol->client->protocol); trigger_error ($msg?$msg:"unknown error: please see back end log for details",E_USER_ERROR); }C:\xampp\htdocs\JavaBridge\java\Java.incexists ?? Also, make sure filename has same case.