From: <php...@li...> - 2006-10-13 01:43:40
|
Hi all. The title of the email says it all! I know PHP like the back of my hand, but know little to nothing about Java. I was able to compile and test the bridge for OS X Server, but I am running into a brick wall trying to understand how to create calls to Java objects (libraries, JAR's, or whatever they are called) and could use a little help from you experts. Hopefully some of you can answer a few questions for me to get me started (ill try to be brief): 1) What are the standard "include" files I need at the top of each of my PHP scripts to utilize the Bridge? 2) How do I gain access to certain Java methods in my PHP scripts? For example if I want to convert a string read from a file into an array of values I think I would use $array_var->toCharArray ($string_var). I believe I need the "java.lang.string" library/class thing (found this in the Java API docs at Sun.com) but I cannot figure out how to enable this class or method in my PHP scripts? 3) I cannot figure out how to instantiate a new class or object. For example a Java API we need to access has a file called "cybsclients15.jar". I used a "java_require ('......cybclients15.jar')" which seems to work (I didn't get any errors). So how do I call or access the classes in that file? For example, there is a class called "Utility" which in turn has a method called "read") in the JAR file. I tried the following: <?php java_require("/Library/WebServer/Documents/cj/simapi-java-5.0.0/lib/ cybsclients15.jar"); $handle = new Java("Utility"); $props = $handle->read("config.properties"); ?> This is supposed to create a handle to the class called "Utility" and then let me use the "read" method to read a configuration file into an array. All I get is the following error that seems to tell me the class does not exist: Fatal error: Uncaught [o(Exception):"java.lang.Exception: CreateInstance failed: new Utility. Cause: java.lang.ClassNotFoundException: Could not find Utility in java_require() path. Please check the path and the SEL and File permissions. Responsible VM: 1.5.0_06@http://apple.com/" at: #-7 php.java.bridge.DynamicJavaBridgeClassLoader.loadClass (DynamicJavaBridgeClassLoader.java:408) #-6 php.java.bridge.SimpleJavaBridgeClassLoader.forName (SimpleJavaBridgeClassLoader.java:162) #-5 php.java.bridge.JavaBridge.CreateObject(JavaBridge.java:499) #0 / Library/WebServer/Documents/cj/simapi-java-5.0.0/samples/nvp/ AuthCaptureSample.php(18): Java::__construct('Utility') #1 {main}] thrown in /Library/WebServer/Documents/cj/simapi-java-5.0.0/samples/ nvp/AuthCaptureSample.php on line 18 Thanks for the help. -- Jon |