This site requires JavaScript, please enable it in your browser!
Greenfoot back
Cygnustar
Cygnustar wrote ...

2011/9/12

Native Loader Problem

Cygnustar Cygnustar

2011/9/12

#
I'm trying to load jFuzzyLogic.jar into my Greenfoot Scenario. I am having problems importing the classes. Here is the code that I am trying to work on:
import net.sourceforge.jFuzzyLogic.FIS;
import net.sourceforge.jFuzzyLogic.FunctionBlock;
public class FuzzyLogicController
{
    static 
    {
        final NativeLoader loader = new NativeLoader();
    
        loader.addClasspath( ".\\+libs\\jFuzzyLogic_v2.0.11" );
        loader.loadClass( "net.sourceforge.jFuzzyLogic.FIS" );
        loader.loadClass( "net.sourceforge.jFuzzyLogic.FunctionBlock" );
    }  

    public FuzzyLogicController()
    {
    }

    public void TestTipper() throws Exception
    {
        String fileName = "tipper.fcl";
		FIS fis = FIS.load(fileName, true);
		if( fis == null ) { // Error while loading?
			System.err.println("Can't load file: '" + fileName + "'");
			return;
		}

		// Show ruleset
		FunctionBlock functionBlock = fis.getFunctionBlock(null);
		functionBlock.chart();

		// Set inputs
		functionBlock.setVariable("service", 3);
		functionBlock.setVariable("food", 7);

		// Evaluate 
		functionBlock.evaluate();

		// Show output variable's chart 
		functionBlock.getVariable("tip").chartDefuzzifier(true);

		// Print ruleSet
		System.out.println(functionBlock);        
    }
}
I have placed jFuzzyLogic_v2.0.11.jar at +libs in the root folder of Greenfoot but Greenfoot an error occurs at the line import net.sourceforge.jFuzzyLogic.FIS; Am I doing something wrong or missing something? Please help!
davmac davmac

2011/9/13

#
The "+libs" folder should be in the root folder of the scenario, not the root folder of Greenfoot.
Cygnustar Cygnustar

2011/9/13

#
It works! Thanks man. I thought I had tried that awhile ago but to no avail. But then, for some reason, it works now. It seemed like I had to restart the system or something. Thanks davmac.
davmac davmac

2011/9/13

#
No problem, glad to help. You usually do have to re-start Greenfoot after putting stuff in there.
You need to login to post a reply.