Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Other Java Products and Servers and the fly likes rules and querys Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Products » Other Java Products and Servers
Bookmark "rules and querys" Watch "rules and querys" New topic

rules and querys

Francisco Mejia

Joined: Oct 12, 2005
Posts: 2
I'm new in jess and I would like to know if there is another way to introduce rules and jess querys in a java aplication instead of using the engine.executeCommand("(defrule rule ....)");. If someone has an example how to declare a rule and a query in java using the jess classes I would appreciate. Thanks
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24193


Welcome to JavaRanch!

You can use the Rete.batch() method, which can read from a file in the filesystem or from a resource on the classpath. Or you can use the Jesp (Jess Parser) class directly, and parse rules and queries (and all other Jess code) from any you provide.

You're probably asking, though, about somehow saying something like

Defrule rule = new Defule("rule-name", "comment");

This is actually now possible in Jess 7 but the code to create a rule is long. Really, really long. And currently undocumented. So I wouldn't try it if I were you.

[Jess in Action][AskingGoodQuestions]
Francisco Mejia

Joined: Oct 12, 2005
Posts: 2
Hi Mr. Friedman-Hill,

Thanks for your answer. Yes, I have solve my problem embedding jess in my java application using Rete.batch() class. Following your advice I did not try to use the last way. Have a good day.
I agree. Here's the link:
subject: rules and querys
jQuery in Action, 3rd edition