Problem with files using prolog (Existence error)

420 views Asked by At

Why would the file run with no problems when using Eclipse but when I create a jar file of the same program I can't run it locally on my pc?

This is the error I get where a is an input and signal.pl is a file I pass located in Desktop:

C:\Users\HP\Desktop>java -jar ADE2.jar a signal.pl
Exception in thread "main" org.jpl7.PrologException: PrologException: error(existence_error(source_sink, a), _0)
        at org.jpl7.Query.fetchNextSolution(Query.java:438)
        at org.jpl7.Query.hasMoreSolutions(Query.java:342)
        at org.jpl7.Query.oneSolution(Query.java:872)
        at org.jpl7.Query.hasSolution(Query.java:950)
        at ADE.executeGorgias(ADE.java:19)
        at ADE.main(ADE.java:41)
1

There are 1 answers

2
Markus Weninger On

I assume that you have two different working directories in your two scenaries.

SWI-Prolog provides the working_directory/2 predicate in the form of working_directory(-Old, +New).

As the documentation states:

Unify Old with an absolute path to the current working directory and change working directory to New. Use the pattern working_directory(CWD, CWD) to get the current directory.

Thus, I would suggest to test working_directory(CWD, CWD) in both cases to see if your working directory differs, which may lead to probelms when working with relative paths.

Edit: You can also use absolute_file_name/3 to ensure that your "Eclipse use case" and your "jar use case" resolve the file in the same way.