From: <php...@li...> - 2008-03-08 17:05:46
|
Thanks again! I tried another approach and I guess I found the reason. Right now I put everything inside a java class and it runs in java with no problem. But once I try to run it in php, it fail to load the file. Here's how it looks like. Test1.java import net.sourceforge.jFuzzyLogic.FIS; import net.sourceforge.jFuzzyLogic.rule.FuzzyRuleSet; public class Test1{ private FIS aFIS; private FuzzyRuleSet aRuleSet; public Test1(){} public String init(){ String fileName = "tipper.fcl"; aFIS = FIS.load(fileName,true); if( aFIS == null ){ return "Can't load file: '" + fileName + "'"; } aRuleSet = aFIS.getFuzzyRuleSet(); if(aRuleSet == null){ return "Can't load rule set"; } return "Initialization succeed"; } public String setRule(double x, double y){ if(aRuleSet == null){ return "Can't access rule set"; } else{ aRuleSet.setVariable("service", x); aRuleSet.setVariable("food", y); aRuleSet.evaluate(); return "" + aRuleSet.getVariable("tip").defuzzify(); } } public String printRuleSet(){ if(aRuleSet == null){ return "Can't print rule set"; } else{ return aRuleSet.toString(); } } } test1.php <?php if(!extension_loaded("java")) require_once("JavaBridge/java/Java.inc"); java_require(".;jFuzzyLogic_1_2_1.jar;Test1.jar"); try{ $temp = new Java("Test1"); echo "<p>" . java_inspect($temp) . "</p>"; echo "<p>" . $temp->init() . "</p>"; echo "<p>" . $temp->setRule(3, 7) . "</p>"; echo "<p>" . $temp->printRuleSet() . "</p>"; } catch(JavaException $ex){ $exStr = java_cast($ex, "string"); echo "<p>Exception occured; mixed trace: " . $exStr . "</p>"; } ?> and the output [class Test1: Constructors: public Test1() Fields: Methods: public boolean java.lang.Object.equals(java.lang.Object) public native int java.lang.Object.hashCode() public java.lang.String java.lang.Object.toString() public java.lang.String Test1.init() public java.lang.String Test1.setRule(double,double) public java.lang.String Test1.printRuleSet() public final native java.lang.Class java.lang.Object.getClass() public final native void java.lang.Object.notify() public final native void java.lang.Object.notifyAll() public final void java.lang.Object.wait() throws java.lang.InterruptedException public final void java.lang.Object.wait(long) throws java.lang.InterruptedException public final native void java.lang.Object.wait(long,int) throws java.lang.InterruptedException Classes: ] Can't load file: 'tipper.fcl' Exception occured; mixed trace: java.lang.Exception: Invoke failed: [[o:Test1]]->setRule((o:double)[o:PhpExactNumber], (o:double)[o:PhpExactNumber]). Cause: java.lang.IllegalArgumentException VM: 1.5.0@http://www.ibm.com/ All files are sitting in the same directory. Any idea? Thanks On Sat, Mar 8, 2008 at 5:48 AM, <php...@li...> wrote: > > [[o:Request$PhpNull]]->toString. > > Instead of a NullPointerException we should throw a custom exception which explains that the user > has passed a PHP null value to the bridge. > > > > > Lesen Sie Ihre E-Mails auf dem Handy. > www.yahoo.de/go > > ------------------------------------------------------------------------- > > > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > php-java-bridge-users mailing list > php...@li... > https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users > |