我正在尝试使用JPL进行Java程序和YAP Prolog的交互.
在我的java文件中,这一行抛出异常:
Query query = new Query("consult", new Term[] { new Atom("test.pl") });
例外如下所示:
Exception in thread "main" jpl.JPLException: this Query's engine is not that which is attached to this thread
at jpl.Query.close(Query.java:511)
at jpl.Util.textToTerm(Util.java:165)
at jpl.Query.Query1(Query.java:183)
at jpl.Query.<init>(Query.java:176)
at Test.main(Test.java:12)
Run Code Online (Sandbox Code Playgroud)
虽然我没有在YAP中发现有人报告同样的问题,但是有些人在SWI中遇到了这个问题,并建议他们验证SWI是使用多线程支持编译的.以防我编译YAP支持多线程,但它没有帮助.
这个问题只发生在OS X中,我在Ubuntu中尝试过,一切正常.
有人知道OS X中此问题的解决方法吗?
我正在使用SWI-Prolog提供的JPL编写Java应用程序,从Java调用Prolog.
我正在使用Eclipse作为IDE.我不知道如何启动我在网上找到的这个例子:
这里是java代码:
package prolog;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import jpl.Atom;
import jpl.Compound;
import jpl.Variable;
import jpl.Term;
import jpl.Query;
import jpl.JPL;
@SuppressWarnings({ "unchecked", "deprecation", "serial" })
public class JavaProlog extends JFrame {
JButton startButton = new JButton("Start");
JTextArea textArea = new JTextArea("A Diagnostic Expert System \n" +
"for respiratory diseases and lung.");
/**
*/
JavaProlog(){
Container cp=getContentPane();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocation (200,200);
setSize (300,200);
setLayout (new …Run Code Online (Sandbox Code Playgroud)