|
From: <php...@li...> - 2007-06-19 17:14:27
|
I am new to the php-java-bridge and am experimenting with it. There
is probably something obvious that I am not seeing, but I cannot get
a simple example Java to PHP application bridge working. I used the
latest Debian packages which are using version 4.0.8a of the php-java-
bridge. I can see via phpinfo() that php-java-bridge is installed and
running via Apache2.2 right now. The following application works fine
(I got it from the examples page):
Java:
public class HelloWorld {
private String hw = "Hello World";
public String getHelloWorld() {
return hw;
}
}
PHP:
<?php
java_require('http://192.168.1.128/java/HelloWorld.jar');
$myObj = new Java('HelloWorld');
// display Hello World
echo (String) $myObj->getHelloWorld();
?>
However, if I change the Java and PHP to the following, then I get
the following exception output:
Hello World
Fatal error: Uncaught [[o:Exception]:"java.lang.Exception: Invoke
failed: [[o:HelloWorld]]->setHellowWorld([o:PhpParserString]). Cause:
java.lang.NoSuchMethodException: setHellowWorld([o:PhpParserString]).
Candidates: [] Responsible VM: 1.5.0_11@http://java.sun.com/" at: #-5
php.java.bridge.JavaBridge.Invoke(JavaBridge.java:1106) #-4
php.java.bridge.Request.handleRequest(Request.java:342) #-3
php.java.bridge.Request.handleRequests(Request.java:388) #0 [internal
function]: Java->__call('setHellowWorld', Array) #1 /home/jhodapp/
projects/java_bridge/HelloWorld.php(9): Java->setHellowWorld('Hello
world, on...') #2 {main}] thrown in /home/jhodapp/projects/
java_bridge/HelloWorld.php on line 9
Changed Java (throws exception):
public class HelloWorld {
private String hw = "Hello World";
public String getHelloWorld() {
return hw;
}
public void setHelloWorld(String incoming) {
hw = incoming;
}
}
Changed PHP (throws exception):
<?php
java_require('http://192.168.1.128/java/HelloWorld.jar');
$myObj = new Java('HelloWorld');
// display Hello World
echo (String) $myObj->getHelloWorld();
$myObj->setHellowWorld((String) "Hello world, once again.");
?>
Once I add my own method in the Java source, it no longer seems to
work. I'm compiling this via "javac HelloWorld.java" and making a jar
via: "jar cvf HelloWorld.jar HelloWorld.class"
Is there something wrong with my setup? The site seems to be good at
helping you get setup with php-java-bridge for your OS environment,
but lacks good documentation from that point.
Thanks,
Jim Hodapp
|