jess-users  

Re: JESS: Is it Possible to Embed Jess Into Java Without the main() method?

Jason Morris
Fri, 08 Jan 2010 06:02:42 -0800

Hi Adeyi,

All the basic information about embedding Jess in a Java app can be found
here:

    http://www.jessrules.com/jess/docs/71/embedding.html

BTW --

Make sure that you call

    engine.reset();

before you call

   engine.run();

else Jess won't be initialized properly.

See http://www.jessrules.com/jess/docs/71/api/jess/Rete.html#reset() for a
listing of all the functions that reset() performs.

Cheers,
Jason
----------------------------------------------------------
Morris Technical Solutions LLC
consult...@morris-technical-solutions.com
(517) 304-5883

On Thu, Jan 7, 2010 at 10:12 PM, Socrates Frangis <soc.fran...@gmail.com>wrote:

> Not sure what you're trying to do, but Jess is embedded as any other Java
> object would be. Check the Jess website for the API.
> Just create a rete object, connect a CLP file to it, add facts, and run.
> Here's a not too great example, but it is an example of just embedding Jess
> in a method, which of course will be ran with the method is called. Does
> this help at all?
>
> Example Code:
>
> import jess.*;
>
> public class SomeJavaObject{
>      //whatever code exists in your object
>     //perhaps analyze members within the object with Jess, whatever...
>     private int x;
>     private double y;
>     private String s;
>
>     //Constructor
>     public SomeJavaObject{
>        x = 1;
>        y = 2.1231;
>        s = "Socrates";
>     }
>
>     public static void exampleMethod(){
>         try{
>             //Create the engine
>             Rete engine = new Rete();
>
>             //Assert Facts - add whatever objects you want in the Rete
> Engine for Jess to analyze
>             engine.add(x);
>             engine.add(y);
>             engine.add(s);
>
>             //Batch the CLP file
>             engine.batch("rules.clp");
>
>             //Run Rule Engine
>             engine.run();
>
>             //Either printout results from Jess to the console through
> (printout t ...)
>             //Or add Java Beans from that contain members which Jess might
> change when a rule is triggered (remember to add a property change listener)
>         }
>         catch (JessException e){e.printStackTrace();
>         }
>     }
> }
>
>
> On Thu, Jan 7, 2010 at 5:11 AM, Adeyi <olufemioyel...@gmail.com> wrote:
>
>>
>> I want to embed Jess into Java code. The Java code is to be called from an
>> eclipse-based IDE. Can I achieve my aim without the use of the main()
>> method
>> in Java? I need help please!!!
>> --
>> View this message in context:
>> http://old.nabble.com/Is-it-Possible-to-Embed-Jess-Into-Java-Without-the-main%28%29-method--tp27059744p27059744.html
>> Sent from the Jess mailing list archive at Nabble.com.
>>
>>
>>
>> --------------------------------------------------------------------
>> To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
>> in the BODY of a message to majord...@sandia.gov, NOT to the list
>> (use your own address!) List problems? Notify owner-jess-us...@sandia.gov
>> .
>> --------------------------------------------------------------------
>>
>>
>


--