How to connect JPL with SWI-Prolog in Mac OS X - java

Hi i have a problem with a jpl interface. I want connect JPL with swi-prolog installed with mac-ports with eclipse. I have a jpl.jar and i have tried to import the jar file in eclipse with build path but i have this error: "no jpl in java.library.path".
So i have copied libjpl.dylib in a /opt/local/lib/swipl-7.1.29/bin/ and when i execute the code i have this error: "Exception in thread "main" java.lang.UnsatisfiedLinkError: /opt/local/lib/swipl-7.1.29/bin/libjpl.dylib: dlopen(/opt/local/lib/swipl-7.1.29/bin/libjpl.dylib, 1): Library not loaded: /Users/janw/stable/lib/swipl/lib/x86_64-darwin13.0.0/libswipl.dylib
Referenced from: /opt/local/lib/swipl-7.1.29/bin/libjpl.dylib
Reason: image not found"

After a anoying waste of time i found the solution about that problem.
First of all, its completely necesary to install swi-prolog via macports, if not, as i did, when you point in the
Djava.library.path=/users/rivax/Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin13.0.0
this exception will apear
Exception in thread "main" java.lang.UnsatisfiedLinkError: /Users/rivax/Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin13.0.0/libjpl.dylib: dlopen(/Users/rivax/Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin13.0.0/libjpl.dylib, 1): Library not loaded: /Users/janw/stable/lib/swipl/lib/x86_64-darwin13.0.0/libswipl.dylib
Referenced from: /Users/rivax/Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin13.0.0/libjpl.dylib
Reason: image not found
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1965)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1890)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1880)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1088)
at jpl.JPL.loadNativeLibrary(JPL.java:100)
at jpl.fli.Prolog.<clinit>(Prolog.java:85)
at jpl.Query.open(Query.java:286)
at jpl.Util.textToTerm(Util.java:162)
at jpl.Query.<init>(Query.java:198)
at consultasProlog.Consultas.consultaFicheroProlog(Consultas.java:19)
at utilidades.RellenarModelo.ejecutarArchivo(RellenarModelo.java:30)
at javaprolog.JavaProlog.main(JavaProlog.java:30)
Java Result: 1
So follow these steps.
port install swi-prolog on terminal , if you dont have install already macports command not found will apear so go to https://www.macports.org/install.php and install macports.
navigate to the path of swi prolog macports installation which mine is
/opt/local/lib/swipl-6.6.6/lib/x86_64-darwin14.0.0
copy this path and set in java.library.path in the java VM as -Djava.library.path=/opt/local/lib/swipl-6.6.6/lib/x86_64-darwin14.0.0
Now .pl with jpl.jar will be able to execute and the consults will run.
Hope it will help you and every person who find this hell problem.
Cheers frank.

Related

Setting up LibPostal (JPostal) on Windows in Java

I'm trying to setup libpostal/jpostal on my Windows 10 machine in a Java environment. I followed the Windows Installation Guide on GitHub.
I am able to see the libpostal folder installed under: C:\xxx\Program Files\libpostal\ with sub folders: .git, autom4te.cache, data, m4, resources etc.
However, when I run:
AddressExpander expander = AddressExpander.getInstance();
I get the following error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jpostal_expander in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at com.mapzen.jpostal.AddressExpander.<clinit>(AddressExpander.java:7)
at jpostal.JPostal.execute(JPostal.java:24)
at global_projects.GlobalMain.main(GlobalMain.java:37)
I normally use Maven for my build. However, since there is currently no Maven repository for JPostal, I am using Gradle.
I followed the solution suggested on this GitHub thread by adding the following gradle.build file, however I still get the same error.
What am I doing wrong?

Can't run the Nand2Tetris Hardware Simulator

I am trying the Nand2Tetris course, and I got to the point where I want to run and test hdl files with the Hardware Simulator. I downloaded the software suit, followed the instruction below and ran:
# I had a dangling symlink issue at the beginning
# and the full path was apparently the way to solve it
chmod +x ~/.../nand2tetris/tools/HardwareSimulator.sh
I tried to run the script with:
./HardwareSimulator.sh
and received the following error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: /usr/lib/jvm/java-17-openjdk-amd64/lib/libawt_xawt.so
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2393)
at java.base/java.lang.Runtime.load0(Runtime.java:755)
at java.base/java.lang.System.load(System.java:1953)
at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:384)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:228)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:170)
at java.base/jdk.internal.loader.NativeLibraries.findFromPaths(NativeLibraries.java:311)
at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:281)
at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2398)
at java.base/java.lang.Runtime.loadLibrary0(Runtime.java:818)
at java.base/java.lang.System.loadLibrary(System.java:1989)
at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:1392)
at java.desktop/java.awt.Toolkit$2.run(Toolkit.java:1390)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at java.desktop/java.awt.Toolkit.loadLibraries(Toolkit.java:1389)
at java.desktop/java.awt.Toolkit.initStatic(Toolkit.java:1427)
at java.desktop/java.awt.Toolkit.<clinit>(Toolkit.java:1401)
at java.desktop/java.awt.Component.<clinit>(Component.java:624)
at HardwareSimulatorMain.main(Unknown Source)
I don't understand what seems to be the problem and why it states (Unknown Source) at the end.
When looking online for a solution I saw it might be a problem with openjdk in this post.
I also found this post but it didn't help me much either.
I am a relatively new Linux user currently on pop OS.
I would really love some help as I am unsure what should I do to fix the problem as well as how to continue the course
Thanks in advance.
Not a linux user but a useful tactic in these cases is to google the first line of the error message ("Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: /usr/lib/jvm/java-17-openjdk-amd64/lib/libawt_xawt.so"), which provides several hints. One of them is to install the missing library, ie: "sudo apt install openjdk-17-jdk"

JCEF initialization issue on MacOS

My Java app which uses JCEF, works perfectly fine in Windows Operating System. But when I try to run this sample application on MacOS Mojave, then it's facing initialization issues. I have added the desired jars and JCEF MacOS libraries/binaries into my project, also added JVM parameter to startup configuration as:
-Djava.library.path=*/jcef/jcef_build/native/Release,
but at the time of running application im facing the folowing error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: /jcef_build/native/Release/libjcef.dylib: dlopen(*/jcef_build/native/Release/libjcef.dylib, 1): Library not loaded: #rpath/Frameworks/Chromium Embedded Framework.framework/Chromium Embedded Framework
Referenced from: */jcef_build/native/Release/libjcef.dylib
Reason: image not found
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at org.cef.CefApp.<init>(CefApp.java:149)
at org.cef.CefApp.getInstance(CefApp.java:237)
at org.cef.CefApp.getInstance(CefApp.java:224)
at MainFrame.<init>(MainFrame.java:70)
at MainFrame.main(MainFrame.java:145)
Please any one suggest what I am missing in running this sample application.

JNI error of SCIP

I got scip optsuite from http://scip.zib.de/#scipoptsuite .
It works fine as a standalone program and with the python interface, but I faced the following JNI error when I ran the example.
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jscip-0.1.darwin.x86_64.gnu.opt.spx in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1865)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at de.zib.jscip.nativ.jni.JniScipLibraryLoader.loadLibrary(JniScipLibraryLoader.java:7)
at JniKnapsack.main(JniKnapsack.java:34)
The OS is OS X 10.10.5.
I compiled JNI with
make soplex GMP=false
make scip GMP=false ZIMPLE=false
The lib directory for JNI (path-to-scipoptsuite/scip-3.2.0/interfaces/jni/lib) contains the followings, and is referenced by LD_LIBRARY_PATH:
jniinc# -> /Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home/include
libjscip-0.1.darwin.x86_64.gnu.opt.spx.so*
libjscip.darwin.x86_64.gnu.opt.so# -> libjscip-0.1.darwin.x86_64.gnu.opt.spx.so
libjscip.so# -> libjscip-0.1.darwin.x86_64.gnu.opt.spx.so
liblpispx.darwin.x86_64.gnu.opt.so
libnlpi.cppad.darwin.x86_64.gnu.opt.so
libscip.darwin.x86_64.gnu.opt.so
libsoplex.darwin.x86_64.gnu.opt.so
scip# -> ../../..
scip.jar
soplex# -> ../../../../soplex-2.2.0
I would be happy if you could give me a suggestion.
Accordiong to mueldgog's advice, I changed the extension to jnilib. Then another error occurred:
Exception in thread "main" java.lang.UnsatisfiedLinkError: /.../scipoptsuite-3.2.0/scip-3.2.0/interfaces/jni/lib/libjscip-0.1.darwin.x86_64.gnu.opt.spx.jnilib: dlopen(/.../scipoptsuite-3.2.0/scip-3.2.0/interfaces/jni/lib/libjscip-0.1.darwin.x86_64.gnu.opt.spx.jnilib, 1): Library not loaded: lib/liblpispx-3.2.0.darwin.x86_64.gnu.opt.so
Referenced from: /.../scipoptsuite-3.2.0/scip-3.2.0/interfaces/jni/lib/libjscip-0.1.darwin.x86_64.gnu.opt.spx.jnilib
Reason: image not found
otools says:
Load command 11
cmd LC_LOAD_DYLIB
cmdsize 72
name lib/liblpispx-3.2.0.darwin.x86_64.gnu.opt.so (offset 24)
In a Linux environment, where I successfully run the same command, lld says
liblpispx.linux.x86_64.gnu.opt.so => /.../scipoptsuite-3.2.0/scip-3.2.0/lib/liblpispx.linux.x86_64.gnu.opt.so (0x00002b66b3d35000)
So I think I should fix the reference to the absolute path on OS X, but don't know how to fix it.
Could you give any advice for this?

Eclipse Error: no jogl in java.library.path

So I'm quite new to eclipse (first week of actually trying to use it to develop stuff.) and I tried to import an example project from http://unfoldingmaps.org/ and upon trying to compile their test project I'm greeted with the error:
Eclipse Error: Exception in thread "Animation Thread" java.lang.UnsatisfiedLinkError: no jogl in java.library.path
Right now my $path sys var looks like this:
C:\csvn\Python25\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\SourceGear\Common\DiffMerge\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\MySQL\MySQL Server 6.0\bin; %JAVA_HOME%;%ANT_HOME%\bin
Is there something that I'm missing? Jogl.jar is in the project but it seems like the project is just skipping over stuff.. help?
It seems that your application requires some sort of native library, you need to specify the parameter -Djava.library.path=/path/to/libs on the VM args field on eclipse.

Categories

Resources