From: <php...@li...> - 2006-09-11 03:19:52
|
Hoy en la tarde, php...@li... dijo: > 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!"); > } > } You should not be printing to System.out, but instead returning a String [untested]: public class HelloWorld { public String sayHello() { return "What up dog!"; } } (I guess static methods also work; I can't remember now) And then use this in PHP [untested, too]: // ... $x = new java("HelloWorld"); printf("HelloWorld says '%s'<br/>", $x->sayHello()); HTH, -- Guti I don't know what your problem is, but I'll bet it's hard to pronounce. -- Dogbert |