• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Embedding Jess in a Java Application  RSS feed

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am new with regards to jess. iam trying to run an example that is provide within the jess manual but i am failing. Can anyone help me with the steps on how to run the pricing engine example that is attached.

it is referred to within the jess manual but i am failing to run it.
 
Saloon Keeper
Posts: 4749
117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess you're referring to http://herzberg.ca.sandia.gov/docs/70/embedding.html. (That would have been useful information to post, by the way.)

i am failing to run it.


What does that mean? What, exactly, did you do, and what, exactly, was the result?
 
Pat Genpatso
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry about that. The example is refered too on page 85 within the manual http://www.jessrules.com/jess/docs/Jess71p2.pdf.

i have installed eclipse and have downloaded the files within the example folder. I do not know how to proceed in order to run the demo
 
Sheriff
Posts: 23713
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To run a Java class with a public static main method in Eclipse, you click on the Run button in the Java perspective. It's the one that looks like a green circle with a rightwards-pointing white arrow.
 
Pat Genpatso
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

I managed to compile successfully some of the classes via command line such as CatalogItem.java, Customer.java and Offer.java.

When i try to compile the rest of the classes, i get the errors below. help me resolve them

examples\pricing_engine\gov\sandia\jess\example\pricing\model>javac Order.java
Order.java:11: error: cannot find symbol
    private Customer customer;
            ^
  symbol:   class Customer
  location: class Order
Order.java:13: error: cannot find symbol
    public Order(Collection theItems, Customer aCustomer) {
                                      ^
  symbol:   class Customer
  location: class Order
Order.java:30: error: cannot find symbol
    public Customer getCustomer() {
           ^
  symbol:   class Customer
  location: class Order
Order.java:16: error: cannot find symbol
            OrderItem item = (OrderItem) it.next();
            ^
  symbol:   class OrderItem
  location: class Order
Order.java:16: error: cannot find symbol
            OrderItem item = (OrderItem) it.next();
                              ^
  symbol:   class OrderItem
  location: class Order
Note: Order.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
5 errors


Thanks for the help so far.
 
Tim Moores
Saloon Keeper
Posts: 4749
117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's most likely a consequence of the source and class files not being in the directories where the compiler expects them. Try compiling them all at once using "javac *.java"

If the code uses packages, you might want to wok through https://docs.oracle.com/javase/tutorial/java/package, particularly https://docs.oracle.com/javase/tutorial/java/package/managingfiles.html
 
Pat Genpatso
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have been able to compile the classes but when i try to run the demo.java, i get the following error;

C:\Work\Patrick_Project\Software\Jess71p2\Jess71p2\examples\pricing_engine\gov\sandia\jess\example\pricing\demo>java Demo.java
Error: Could not find or load main class Demo.java
 
Tim Moores
Saloon Keeper
Posts: 4749
117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Demo.java is a source file - class files are what gets executed. Try "java Demo" instead.
 
Pat Genpatso
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Same error;

C:\Jess71p2\Jess71p2\examples\pricing_engine\gov\sandia\jess\example\pricing\demo>java Demo
Error: Could not find or load main class Demo
 
Bartender
Posts: 4050
54
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is your build (compiled) class files are located? You may have to run the command from the top level of the directory hierarchy and set the "classpath" to the appropriate path(s) to find the dependent classes. See how you can set the classpath here
 
Pat Genpatso
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have set the class path for the libraries and classes. Iam also running the command from the top level directory but i get the same error;

C:\Jess71p2\examples\pricing_engine>java -cp .:..\..\lib\jess.jar gov.sandia.jess.example.pricing.demo.Demo

Error: Could not find or load main class gov.sandia.jess.example.pricing.demo.Demo
 
Tim Moores
Saloon Keeper
Posts: 4749
117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Given that information, the class file should be at

C:\Jess71p2\examples\pricing_engine\gov\sandia\jess\example\pricing\demo\Demo.class

Is it?
 
Pat Genpatso
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes it is.

Untitled1.png
[Thumbnail for Untitled1.png]
 
Tim Moores
Saloon Keeper
Posts: 4749
117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK. That doesn't show the directory hierarchy, but I'll take your word for it. And just to make sure: class Demo is in package gov.sandia.jess.example.pricing.demo?
 
Pat Genpatso
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes it is.
 
Vijitha Kumara
Bartender
Posts: 4050
54
Chrome Fedora Hibernate
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your -cp entries should be separated by ";" not ":" in Windows.
 
Pat Genpatso
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
same error even when i change from : to ;
 
Vijitha Kumara
Bartender
Posts: 4050
54
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You seem to have some conflicts in your directories, why you have jess.jar along with your class/source files as in above attachment, but you refer that from another location?

You may try compiling with -d option and point that to the -cp when running so that your class/jar files are separated from source (though this is not a mandatory to run, but just to make sure...)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!