PHP Java Bridge Setup

The place for general PHP questions and hints for PHP on IBM i
Post Reply
Posts: 5
Joined: Thu Dec 08, 2011 9:06 pm

PHP Java Bridge Setup

Post by symgym » Thu Dec 08, 2011 9:24 pm

I can't instantiate a class from a .jar file. the new java(class) fails. Details below:

I have zendserver CE installed with latest version as of 12/8/2011 with jre and javabridge.

The jar file is in the correct location

The included php test script runs perfectly.
Thursday, December 08, 2011 at 3:19:25 PM Eastern Standard Time class java.lang.System Java version=1.6.0_29
Java vendor=Sun Microsystems Inc.

OS=Windows 7 6.1 on x86

JAR FILE: myWebTest.jar
package: com.research.phpjava.db.example
class: MyWebTest
String testWeb(String myName) {

return "Hello " + myName;

PHP SCRIPT testObject.php
java_require('c:/program files/zend/zendserver/bin/myWebTest.jar');
//I have tried all the following and each has same error.
#$jObj = new Java('com.research.phpjava.db.example.MyWebTest');
#$jObj = new Java('com.research.phpjava.db.example.myWebTest');
$jObj = new Java('MyWebTest');
#$jObj = new Java('myWebTest');
#$jObj = new Java('myWebTest.MyWebTest');
#$jObj = new Java('MyWebTest.myWebTest');
#$jObj = new Java('myWebTest');

print $jObj->testWeb("jim");

Error (for all situations)
Call to a member function testWeb() on a non-object ....

Please help.

Posts: 171
Joined: Fri Apr 10, 2009 12:41 am
Location: Toronto

Re: PHP Java Bridge Setup

Post by chris_hird » Tue Dec 20, 2011 9:23 pm


Code: Select all

java_require('c:/program files/zend/zendserver/bin/myWebTest.jar');

Code: Select all

java_require('c:/program files/zend/zendserver/bin/MyWebTest.jar');
Sorry ignore the above, I see you named the class MyWebTest but the jar is in fact called myWebTest.jar.. And I assume you have that in your Java Path so that is can be found OK.

Shield Advanced Solutions Ltd
Home of JobQGenie and the Receiver Apply Program

Post Reply