0

I am trying to get Java and Prolog to work together (on OS X 10.11.1). What I want, is just to input my Prolog Queries from Java.

When I run Java code such like

PrologProcess process = Connector.newPrologProcess();
process.queryOnce(query);

I get the following Error:

java.io.IOException: Cannot run program "swipl": error=2, No such file                  or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
...

First I did was adding entries to my PATH variable as I suppose that SWIProlog could not been found, but it showed no effect. My PATH contains:

/opt/local/lib/swipl-7.2.3/
/opt/local/lib/swipl-7.2.3/bin
/opt/local/lib/swipl-7.2.3/bin/x86_64-darwin15.0.0/swipl
/opt/local/lib/swipl-7.2.3/bin/swipl.home
/Applications/SWI-Prolog.app/Contents/swipl/lib/jpl.jar
/Applications/SWI-Prolog.app/Contents/swipl/bin/x86_64-       darwin15.0.0/swipl
/Applications/SWI-Prolog.app/Contents/swipl/
/Applications/SWI-Prolog.app/Contents/

Hope somebody knows whats up. Any ideas?

false
  • 10,264
  • 13
  • 101
  • 209
Olia
  • 1
  • 2

1 Answers1

2

Several of your PATH entries make no sense. Try on Terminal.app window:

$ which swipl

That will tell where the swipl executable is located. As it seems that you also have installed the SWI-Prolog.app GUI application, the correct path to the executable is:

/Applications/SWI-Prolog.app/Contents/MacOS/

Also note that Mac OS X GUI applications don't run on top of a shell and thus don't inherit the environment variable definitions that you use for command-line commands. But Eclipse allows in one of its preferences panel to define environment variables there.

Paulo Moura
  • 18,373
  • 3
  • 23
  • 33
  • thank You very much! unfortunately the problem is not solved the error message is: – Olia Nov 27 '15 at 12:11
  • // Field descriptor #8 Lorg/cs3/prolog/connector/internal/process/socket/JackTheProcessRipper; – Olia Nov 27 '15 at 12:17
  • The connection between PDT and the SWI-Prolog process uses sockets. Check that the SWI-Prolog process is accepting connections in the Mac OS X Security & Private control panel under Firewall Options. – Paulo Moura Nov 27 '15 at 12:26
  • Compiled from SocketServerStartAndStopStrategy.java (version 1.7 : 51.0, super bit) public class org.cs3.prolog.connector.internal.process.socket.SocketServerStartAndStopStrategy implements org.cs3.prolog.connector.internal.process.ServerStartAndStopStrategy { – Olia Nov 27 '15 at 12:29
  • the message i see that the source attachment does not contain the source for the file socket ServerStartAndStopStrategy.class ... ist it not seen? not compatible or not available? – Olia Nov 27 '15 at 12:36
  • Once the structure is build correctly and intelligent, IT WORKS SOO ELEGANT, AND IT IS SOOOO MIGHTY! JUST AMAZING!!! – Olia Dec 09 '15 at 10:00