简体   繁体   中英

How can I use a GUI debugger on the Prolog code that runs inside a Java app through JPL?

I'm developing a Java+Prolog application through the JPL bridge. The main application is in Java and it calls the Prolog code using Query.oneSolution("doPrologStuff(here)")

I tried running the GUI debugger/tracer using Query.hasSolution("gtrace") but it throws an exception:

Exception in thread "main" jpl.PrologException: PrologException: error(existence_error(procedure, /(gtrace, 0)), context(:(system, /('$c_call_prolog', 0)), _0))
    at jpl.Query.get1(Query.java:336)
    ...

(Same goes for "guitracer")

Calling gtrace. works well when I run the Prolog code in swipl directly.

When I try Query.hasSolution("trace") it lets me debug the code using the text console, but that's not what I'm looking for. Any ideas how to enable the GUI debugger?

I'm using Eclipse on Ubuntu to develop, but I can try other tools if that helps :)

You need to attach Prolog's graphical environment (xpce). You can do that by loading the file swi('swipl.rc'). The next question is whether or not event dispatching happens. That depends on the setup. If you use the latest 5.11.18/5.10.4 versions, you can set the Prolog flag xpce_threaded to true, which causes SWI-Prolog to run the development tools in their own thread (currently only works on Unix/Linux systems).

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