[英]Restarting Prolog engine from Java using JPL
In one java application that uses JPL to interact with Prolog, I want to be able to restart the prolog engine with different settings. 在一个使用JPL与Prolog进行交互的Java应用程序中,我希望能够使用不同的设置重新启动Prolog引擎。 As an example, I would like to change from SWI to YAP (I configure which engine to use this with the method
JPL.setNativeLibraryDir
with the path of the right native library I need to use). 例如,我想从SWI更改为YAP(我使用方法
JPL.setNativeLibraryDir
配置要使用此引擎的引擎, JPL.setNativeLibraryDir
带有需要使用的正确本机库的路径)。
So after changing the JPL configuration, I was trying to halt the already running prolog engine in order to restart it again afterwards with JPL.init()
. 因此,在更改了JPL配置之后,我试图停止已经运行的prolog引擎,以便随后使用
JPL.init()
重新启动它。
First I took a look to JPL.halt()
, but the documentation says it is deprecated and the comments in the source code of the method said that it is no-op. 首先,我看了一下
JPL.halt()
,但是文档说它已被弃用,并且该方法的源代码中的注释说它是no-op。
Afterwards, I tried to just launch a query with 'halt', but although I see in the console "YAP execution halted" as expected, my java application is also halted (!). 之后,我尝试仅使用'halt'启动查询,但是尽管我在控制台中看到“ YAP执行已停止”,但我的Java应用程序也已停止(!)。
Is there a way to restart the logic engine using JPL without killing my java application ? 有没有一种方法可以使用JPL重新启动逻辑引擎而不杀死我的Java应用程序?
why not using a batch file to run scripts. 为什么不使用批处理文件来运行脚本。 first you can have /Applications/swi -l your/swi/code and then use halt inside your prolog code so that it halts after execution.
首先,您可以使用/ Applications / swi -l your / swi / code,然后在您的序言代码中使用halt,以便在执行后暂停。 You can run your batch file inside java using runtime method.
您可以使用运行时方法在Java内部运行批处理文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.