Lets Java call any logic goal through a PrologEngine object, and for Prolog to call back any method through a javaMessage predicate, while passing Java objects and Prolog terms between languages. Both primitives are recursive and open-ended type wise.
XSBSubprocessEngine engine = new XSBSubprocessEngine("MyXSBpath");
if (engine.deterministicGoal("writeln('Hello, Prolog world'), javaMessage('java.lang.System'-out,println(string('Hello, Java world!'))")
System.out.println("This goal succeeded");
Java can create a number of local or even remote engines. It then calls Prolog through a method whose most general variant is:
… which binds (serialized) Java objects into their Prolog representations in the variables named in the second parameter above; on each solution the Prolog code should bind the result vars with serialized object specifications. On the other side, Prolog uses a dual primitive:
The Java bridge comes also with a Prolog listener – where you can test
javaMessage – and a few simple term visualization aids (old screenshot gallery elsewhere); but much more is available in Studio, which includes this bridge.
- Old JELIA 2004 paper, which explains the architecture
- Prolog API, FAQ: please see wiki
- Download and install from here
The InterProlog Java/Prolog bridge can be used for server and desktop JVM environments, not for mobile; it is supplied “as is” and without warranties. It can be extended, adapted or integrated on demand; please contact us.
Historical note: This tool originated in another company back in 1999, than moved on to yet another in 2000, until finally landing at InterProlog Consulting in 2014; most of its development happened in 1999-2002 and 2012-2015: older versions and obsolete information can be found at the old Declarativa site.