New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using JPL with Java 8 on Mac OS X issues #2
Comments
As it seems the jpl build is now broken on my machine and it merely includes the old version, this seems a good time to look into this. The first question is which version of Java one is supposed to install how on MacOS? Somehow, my El Captain as a "Java for OS X 2015-001" disk on the desktop. Trying to install it results in some warnings that this is a legacy old version and one should download Java from java.com. Is that what I should be doing for building JPL? Is that what people who actually use Java on MacOS do? If I get it build, I might be able to add code to jpl.pl that automates the step above to fix the link target for libjpl.dylib. |
On 07/12/2015 16:30, Jan Wielemaker wrote:
Of "Java for OS X 2015-001", Apple say: This package is exclusively intended for support of legacy software If you need Java, download the latest version of Java for OS X Oracle's is kinda the reference implementation. For now, JPL should work fine with Java 6.
Yes if they take Apple's advice ;-) but I guess some will install the
Are you aiming to (be able to) build a binary SWI Prolog for Mac OS X I have received an early Xmas prezzie of a 7 yr old MacBook Pro on Paul Singleton |
I pushed some stuff that may hopefully resolve this. Building on the Mac now finds and uses the Oracle Java. There is a library for the Mac jpl_config.pl that provides I hope that is enough ... |
After git pull, deleting my installed version, and rebuilding, I get:
Calling the |
Thanks for testing. Should we consider this `good enough' or is there an easy way to make this better? Note that we might not be able to write to libjpl.dylib, there may be no Java at all, etc. If you think this is good enough, please close. |
Any reason to not automate calling the |
I'm still encountering this with Java 9. However, it looks like it may in fact be a regression in the JDK itself, as apparently earlier Java 8 JDKs would trigger the "No Java runtime present" dialog when started via JNI (JDK-7131356). |
That seems unrelated. This topic was about finding the Java .dylibs. As the path to find them must be compiled into libjpl.dylib binary distributions need to go through a process of finding the right JDK and updating libjpl.dylib. |
There's still an issue with |
As I understand it, Java9 dropped |
Correct. As far as I can tell JPL works under Java 9, but so far I've only been able to use it from the Java side - trying to use JPL within SWI-Prolog directly causes the "No Java runtime present" message. |
Update |
I'm fairly certain at this point that the problem is within the JDK itself. I just realized that the majority of the examples use Swing, and when I run |
Might be an Apple Java issue. There have been problems with swing this in the past too. Shall we close this? |
As long as you don't touch AWT, this appears to work. The latest version also solves the problem I had where Homebrew wasn't building JPL with the As far as I can tell, everything now "works" with JPL and Java 9 under macOS, minus an internal macOS JDK bug that can be triggered if you call any code that uses AWT (which includes Swing):
However, if you avoid AWT, it works fine:
|
Is this true Jan? My students taking the course now (Sept 2018) said that: "As the homebrew version does not come with the JPL library (an issue on the homebrew github as been opened about this), the second step is therefore to buid the library from source. Alternatively, you can download the already compiled libjpl.dylib and copy it in:" I am asking because your post is from Dec 2017 I do not have a Mac but they (students) devised this plan to make it work: https://github.com/ssardina-research/packages-jpl/wiki/JPL-under-Mac-OS |
MacPorts is an alternative to Homebrew for installation on macOS. Did you tried it to check if it also have an issue with JPL? I'm the maintainer of the portfile. But, as I use the git version, there have been quite some time since I last used the MacPorts install. |
It is true that you can just graph a libjpl.dylib, jpl.pl and jpl.jar from some version and dump it into another with quite a wide variety of versions as both the C API of Prolog and Java are pretty stable. As your student describes, notably on the Mac you have to do some fiddling with the link paths though. On Windows, just make sure the dll and exe are all in the same dir. On Linux it will typically also wok out of the box. |
On Mac OS X there is a command,
java_home
, that returns the path for the user's enabled and preferred JVMs in the Java Preferences application. This command is Apple's advised way of defining the JAVA_HOME environment variable. On my system I get:The user can add to its
~/.profile
file (or equivalent) the line:SWI-Prolog build script picks the value of the
JAVA_HOME
environment variable but there's a problem. The generatedlibjpl.dylib
looks into the wrong place as you can check by typing:This can be corrected by typing:
Still, if you try a JPL call (e.g.
jpl:jpl_call/4
), your SWI-Prolog process will end with an error that "No Java runtime present, requesting install." and a system prompt to install Java 6! If you sigh, throw your hands in the air, surrender, and install Java 6 then JPL will happily work using Java 8. I suspect some lingering linking issue that the fix above is not enough to correct. Is possible that the problem is in the following line in the JPL Makefile:But I have no idea how to fix and still generate a
.dylib
. Any hints?The text was updated successfully, but these errors were encountered: