简体   繁体   中英

Calling a Java application from CLIPS

I have a runnable jar: help.jar, and I need to call it from a rule in CLIPS, as

(defrule ask-shape
    (not (shape ?))
    => 
    (bind ?answer (ask-question "What is the shape?"))
    (while (eq ?answer help) do
       (help) ;; calling the java function
       (bind ?answer (ask-question "What is the shape?")))
    (assert (shape ?answer)))

How can I do it?

Read the CLIPS Advanced Programming Guide for instructions on creating user-defined functions which will allow you to call C code from a CLIPS program (such as calling "(help)" in your ask-shape rule). Use a search engine and search for "how to call Java from C". You'll get hits like this: https://www.codeproject.com/Articles/22881/How-to-Call-Java-Functions-from-C-Using-JNI .

Alternately if you don't need any interaction between CLIPS and the Java code you code use the system command from your rule: (system "java -jar help.jar").

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM