running the jpl examples

174 views
Skip to first unread message

w.pa...@tudelft.nl

unread,
May 9, 2016, 9:06:04 AM5/9/16
to SWI-Prolog
How do I run the JPL examples? OSX Mavericks , using SWI Prolog develop version, applied './built'.

If I run the test-java.sh script, it seems that that just runs  the tests in src/java/org/jpl7/test/TestJUnit

If I run run.sh in say examples/java/Test2, I get 

JPL demo: Test2


Error: A JNI error has occurred, please check your installation and try again

Exception in thread "main" java.lang.NoClassDefFoundError: org/jpl7/Term

at java.lang.Class.getDeclaredMethods0(Native Method)

at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)

at java.lang.Class.privateGetMethodRecursive(Class.java:3048)

at java.lang.Class.getMethod0(Class.java:3018)

at java.lang.Class.getMethod(Class.java:1784)

at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)

at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)

Caused by: java.lang.ClassNotFoundException: org.jpl7.Term

at java.net.URLClassLoader.findClass(URLClassLoader.java:381)

at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)

at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

... 7 more


I tried to set many environment variables, including LD_LIBRARY_PATH, SWI_HOME_DIR, PLBASE, DYLD_LIBRARY_PATH, JUNIT, .... Without that it did not even come that far. I figured all that from the source code as I could not find docs...

w.pa...@tudelft.nl

unread,
May 9, 2016, 9:12:22 AM5/9/16
to SWI-Prolog
One thing, I did not install SWI, I only compiled it with the build command. This is because I just need to test something without damaging my existing installation that I need for regular work.

Jan Wielemaker

unread,
May 9, 2016, 9:36:44 AM5/9/16
to w.pa...@tudelft.nl, SWI-Prolog
Looks like it cannt find jpl.jar. This is pretty hard to setup. If
DYLD_LIBRARY_PATH and JUNIT are setup fine, "make check" in the JPL
directory should work. I'd delay the rest until all is installed ...

Cheers --- Jan
> --
> You received this message because you are subscribed to the Google
> Groups "SWI-Prolog" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to swi-prolog+...@googlegroups.com
> <mailto:swi-prolog+...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/swi-prolog.
> For more options, visit https://groups.google.com/d/optout.

w.pa...@tudelft.nl

unread,
May 9, 2016, 9:41:12 AM5/9/16
to SWI-Prolog, w.pa...@tudelft.nl
Thanks for the quick response. I will give it a try with just the two env vars as you indicate

I can not "install" as I mentioned. The old version must remain working.

Paulo Moura

unread,
May 9, 2016, 9:43:50 AM5/9/16
to w.pa...@tudelft.nl, SWI-Prolog

> On 09/05/2016, at 14:41, w.pa...@tudelft.nl wrote:
>
> Thanks for the quick response. I will give it a try with just the two env vars as you indicate
>
> I can not "install" as I mentioned. The old version must remain working.

Can't you install on an alternative location? You can define a different installation prefix by editing the "build" file.

-----------------------------------------------------------------
Paulo Moura
Logtalk developer

Email: <mailto:pmo...@logtalk.org>
Web: <http://logtalk.org/>
-----------------------------------------------------------------




w.pa...@tudelft.nl

unread,
May 9, 2016, 9:51:05 AM5/9/16
to SWI-Prolog, w.pa...@tudelft.nl
Ok, I did this

* make clean
* downloaded file:///Users/wouter/Desktop/swipl-7.3.20/packages/jpl/junit-4.11.jar
setenv JUNIT /Users/wouter/Desktop/swipl-7.3.20/packages/jpl/junit-4.11.jar
setenv DYLD_LIBRARY_PATH /Users/wouter/Desktop/swipl-7.3.20/lib/x86_64-darwin13.4.0:/Users/wouter/Desktop/swipl-7.3.20/packages/jpl
* make check

This gives

(cd src/java && /Volumes/apps/Xcode.app/Contents/Developer/usr/bin/make test_jar)

make[1]: Nothing to be done for `test_jar'.

if [ -r jpltest.jar ]; then \

  DYLD_LIBRARY_PATH="" ../swipl.sh  -q -f test_jpl.pl -g run_tests,halt -t 'halt(1)' ; \

else \

  echo "No jpltest.jar; maybe junit is not installed?" ; \

fi

No jpltest.jar; maybe junit is not installed?

JUNIT= JAVA=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/java JAVA_PRELOAD= ./test-java.sh

Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 7.3.20)

Copyright (c) 1990-2015 University of Amsterdam, VU Amsterdam

SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,

and you are welcome to redistribute it under certain conditions.

Please visit http://www.swi-prolog.org for details.


For help, use ?- help(Topic). or ?- apropos(Word).



% halt

Error: Could not find or load main class junit.textui.TestRunner

make: *** [check_java] Error 1


Note that there are two different error messages.

I checkked that TestRunner class is inside the junit jar.

I also tried to unzip the junit jar file and point to the unzipped folder. Makes no difference.

w.pa...@tudelft.nl

unread,
May 9, 2016, 9:53:04 AM5/9/16
to SWI-Prolog, w.pa...@tudelft.nl
>Can't you install on an alternative location? You can define a different installation prefix by editing the "build" file. 


I dont know. Is that even necessary? Would the test run if I did that? I just want to run one test, to see if a bug reproduces in the latest version. 

w.pa...@tudelft.nl

unread,
May 9, 2016, 11:04:07 AM5/9/16
to SWI-Prolog, w.pa...@tudelft.nl
I tried a completely different approach so that I can actually see what is going on without having to rely on scripts  that I do not understand

I did this in the Zahed example

javac Zahed.java -cp ../../../jpl.jar 


and then

 java -cp .:../../../jpl.jar -Djava.library.path=/Users/wouter/Desktop/swipl-7.3.20/packages/jpl:/Users/wouter/Desktop/swipl-7.3.20/lib/x86_64-darwin13.4.0 -DSWI_HOME_DIR=/Users/wouter/Desktop/swipl-7.3.20 Zahed


Gives me this

[FATAL ERROR: at Mon May  9 17:01:04 2016

Not a SWI-Prolog saved state]


Maybe this one is easier to fix?

w.pa...@tudelft.nl

unread,
May 9, 2016, 11:19:28 AM5/9/16
to SWI-Prolog, w.pa...@tudelft.nl
I read here

that there is supposedly a boot32.prc or boot64.prc in the SWI_HOME_DIR. I dont see it. Did something fail during the built?

BTW src/swipl runs fine. 

Jan Wielemaker

unread,
May 9, 2016, 3:35:27 PM5/9/16
to w.pa...@tudelft.nl, SWI-Prolog
On 05/09/2016 05:19 PM, w.pa...@tudelft.nl wrote:
> I read here
> http://www.swi-prolog.org/FAQ/FindResources.html
>
> that there is supposedly a boot32.prc or boot64.prc in the SWI_HOME_DIR.
> I dont see it. Did something fail during the built?

It is compiled as swipl.prc in the build directory and installed as
boot32.prc or boot64.prc.

I go with Paulo. Just install to a different directory if you want to
keep your existing installation. Note that by default, the system is
installed in $prefix/lib/swipl-<version> and you can call a particular
version as $prefix/lib/swipl-<version>/bin/<arch>/swipl. Only if you
set --disable-libdirversion" a new install overwrites the old one.

Cheers --- Jan

>
> BTW src/swipl runs fine.
Reply all
Reply to author
Forward
0 new messages