From: <php...@li...> - 2006-09-10 23:40:45
|
I am going crazy with this. Any help would be greatly appreciated. I just can't seem to understand how to communicate to java classes via PHP. I know very little about Java, so am just trying to get the basics working before I go further with my project. I'm sure this is ridiculously easy for you Java folks, but I am very confused - I must be going about this the wrong way: I compiled a java class into a file called "HelloWorld.jar": import java.util.*; public class HelloWorld { public static void main (String args[]) { // insert code here... System.out.println("What up dog!"); } } Then I created a PHP script to try and make a call to this using the PHP/Java bridge: <?php require_once('php_Java.php'); $dir = dirname($_SERVER['SCRIPT_FILENAME']); java_require($dir."/HelloWorld.jar"); $x = new JavaClass("HelloWorld"); $y = new java_class("HelloWorld"); $z = new java("HelloWorld"); echo "=== CAST AS STRING ===<br/>"; echo (string)$x."<br/>"; echo (string)$y."<br/>"; echo (string)$z."<br/>"; echo "=== JAVA VALUES ===<br/>"; echo (java_values($x))."<br/>"; echo java_values($y)."<br/>"; echo (java_values($z))."<br/>"; echo "<p>-- END --"; ?> And when I fire this up in Safari to look at the results, I get: === CAST AS STRING == class HelloWorld class HelloWorld HelloWorld@aed5f9 === JAVA VALUES === class HelloWorld class HelloWorld HelloWorld@aed5f9 -- END -- Why doesn't this thing print out my text. What the heck am I doing wrong? Any help appreciated. Jon |