I have a expert system written in prolog that gives me problems when I run it from a java interface. The problems are related to the comunication of the output. I tried Streams but (only with this project) they don't work fine, the application apparently freezes at the time of writing the txt file, i do something like this :
myFunction(CurPlace, Place) :-
open('text.txt',write,Stream), nl(Stream),
write(Stream,'You cant go from '), write(Stream,CurPlace), write(Stream,' to '), write(Stream,Place), nl(Stream),close(Stream),
fail.
At the end of the writing i read the txt with java, with all my old systems this method worked fine, but with this, maybe for the inference or for the recursive calls, something goes wrong(java-side, because if I run it directly from swiprolog all goes fine)! So I decided to use jpl_get and call, but I'm new at this. I need some help! In my interface I have a jtextarea that print all the output from the prolog system. I call it "jTextAreaOUTPUT", this component is in my java class Interface.
My project folders are (in windows): "main_folder" then inside I have (like all the eclipse project) src,bin... I placed the prolog system pl file in the main_folder so the path to the interface.java is : src/mypackage/interface.java How can i print my example message "Start Message" in my jtextarea ? I tryed this :
start:- jpl_get( 'src.mypackage.interface', jTextAreaOUTPUT, X),
jpl_call(X,append,['Start Message\n']).
...and in my Java application i call the query in this way :
public static void CallQuery(String t2){
Query q2 = new Query(t2);
try{
q2.hasSolution();
} catch (Exception e) {
}
}
t2 is "start" when i call it from the main()! So when i run it, the system give me the "ClassNotFoundException"!
Question 1)Can someone give me a good example that does what I want ?
Question 2)What is the role of the variable X in jpl get and call ?
Question 3)If i want to print a variable how can I do that ?