Search code examples
javajess

Jess engine.batch fails in jar package


I would like to execute constructs file located under src directory from a java file using:

engine.batch("src/constructs.clp");

When I run the program by compiling in Eclipse I have no problem. However, when I create Runnable Jar by exporting, my program fails to execute src/constructs.clp file.

Any help will be greatly appreciated.

Below is a part of the error message I get:

Jess reported an error in routine batch.

      Message: Cannot open file.
        at jess.Batch.findDocument(Unknown Source)
        at jess.Batch.batch(Unknown Source)
        at jess.Batch.batch(Unknown Source)
        at jess.Batch.batch(Unknown Source)
        at jess.Batch.batch(Unknown Source)
        at jess.Rete.batch(Unknown Source)

Solution

  • The program fails to execute because there is no src folder inside the jar. You can check by opening the jar by any unzip software like winrar.

    The program should work if you put the constructs.clp file in same directory of the java program that uses it and then call engine.batch("constructs.clp");