Skip to content
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

[Mac OS X] To open "this Java application" you need to install the legacy Java SE 6 runtime. #160

Closed
e9t opened this issue Oct 24, 2015 · 10 comments

Comments

@e9t
Copy link

e9t commented Oct 24, 2015

Some users of KoNLPy reported that upon invoking JPype on a Mac, we get the following error message:

No Java runtime present, requesting install.

and Python crashes with the following popup:

81662794-543a-11e5-96f5-4dcfcc9f3fc1

I found that the same issue was reported for rJava, and they say this is an official Java 1.8 bug.

There seem to be two ways to work around this problem:

  1. For the user: Install Java 1.6
    [discussion]
  2. For jpype: Call libjli.dylib instead of libjvm.dylib
    [example]
    • libjvm.dylib: '/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/server/libjvm.dylib'
    • libjli.dylib: '/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre/lib/jli/libjli.dylib'

I've tried the latter option for KoNLPy and the crashing went away, but my pre-existing code returned errors like the following:

TypeError: Package kr.lucypark.kkma.KkmaInterface is not Callable
@marscher
Copy link
Member

I do not think that we can handle this issue on our side. If there would exist a functional workaround, I'd be happy to accept it.

@rdllopes
Copy link

rdllopes commented Dec 6, 2016

Hi, all. I think I am little lost. I didn't get it how @e9t managed to work around the issue. jpype currently tries to find libjvm.so what it would not happen in mac os X as is. I created symbolic link libjvm.so pointing to libjvm.dylib. However, the native library (_jpype.cpython-35m-darwin.so)
expects the static library and it refuses to proceed. @e9t, could you clarify your work around, please.

@justussc
Copy link
Contributor

justussc commented Dec 7, 2016

hi @rdllopes,

you can just start your jvm with jpype.startJVM('/path/to/libjli.dylib') (inserting the correct path) assuming that you are using the latest jpype version from git.
i never submitted a pull request for changing the _libfile in jpype._darwin.DarwinJVMFinder to libjli.dylib because i am not aware of the implications. but one has to use that file, as the jni methods are in this 'java legacy interface' library on mac os. while on all other platforms i've used they are in the normal libjvm.

@marscher
Copy link
Member

marscher commented Dec 7, 2016

If the LinuxJVMFinder is used then sys.platform does not evaluate to "darwin" anymore?!
https://github.com/originell/jpype/blob/master/jpype/_core.py#L105

@justussc
Copy link
Contributor

justussc commented Dec 7, 2016

that is indeed is suspicious that he said it was searching for libjvm.so.

but even the DarwinJVMFinder does not work for the jvms i tried. one would have to change https://github.com/originell/jpype/blob/master/jpype/_darwin.py#L35 to self._libfile = "libjli.dylib"

@marscher
Copy link
Member

marscher commented Dec 7, 2016

Okay, I will just change it.

marscher added a commit to marscher/jpype that referenced this issue Dec 7, 2016
akoeplinger added a commit to akoeplinger/java.interop that referenced this issue Oct 25, 2017
…6 popup on OSX

If you don't have the legacy Java6 installed then the call to JNI_CreateJavaVM() will result
in a popup requesting you to install it and abort, even if you call the libjvm.dylib
that's included as part of JDK8.

According to jpype-project/jpype#160 and https://bugs.openjdk.java.net/browse/JDK-7131356
this is a Java8 bug and the recommended fix is to call into libjli.dylib instead.

Indeed this fixes the issue and the popup no longer shows up.
jonpryor pushed a commit to dotnet/java-interop that referenced this issue Oct 25, 2017
#198)

If you don't have the legacy Java 6 installed on macOS, then calling
`JNI_CreateJavaVM()` will result in a popup requesting you to install
the legacy Java 6 VM then abort, *even if* you call the
`libjvm.dylib` that's included as part of JDK8:

	**To open "this Java application" you need to install the legacy Java SE 6 runtime.**
	
	Click "More Info..." to visit the legacy Java SE 6 download website.
	
	[More Info...] [OK]

This is due to a [Java 8 bug][jdk7131356], and a
[suggested solution][jdkfix] is to instead use `libjli.dylib`.

[jdk7131356]: https://bugs.openjdk.java.net/browse/JDK-7131356
[jdkfix]: jpype-project/jpype#160

Update `JdkInfo.props` so that `$(JdkJvmPath)` uses `libjli.dylib`
instead of `libjvm.dylib`, removing the above warning dialog.
Redth pushed a commit to Redth/java.interop that referenced this issue Oct 26, 2017
dotnet#198)

If you don't have the legacy Java 6 installed on macOS, then calling
`JNI_CreateJavaVM()` will result in a popup requesting you to install
the legacy Java 6 VM then abort, *even if* you call the
`libjvm.dylib` that's included as part of JDK8:

	**To open "this Java application" you need to install the legacy Java SE 6 runtime.**
	
	Click "More Info..." to visit the legacy Java SE 6 download website.
	
	[More Info...] [OK]

This is due to a [Java 8 bug][jdk7131356], and a
[suggested solution][jdkfix] is to instead use `libjli.dylib`.

[jdk7131356]: https://bugs.openjdk.java.net/browse/JDK-7131356
[jdkfix]: jpype-project/jpype#160

Update `JdkInfo.props` so that `$(JdkJvmPath)` uses `libjli.dylib`
instead of `libjvm.dylib`, removing the above warning dialog.
dmitry-timofeev pushed a commit to jni-rs/jni-rs that referenced this issue Mar 23, 2020
This is a workaround for the legacy Java SE6 popup on MacOS.

If you don't have the legacy Java6 installed then the call to
JNI_CreateJavaVM() will result in a popup requesting you to install it
and abort, even if you call the libjvm.dylib that's included as part of
JDK8.

According to jpype-project/jpype#160 and
https://bugs.openjdk.java.net/browse/JDK-7131356 this is a Java8 bug and
the recommended fix is to call into libjli.dylib instead.
@andybrucenet
Copy link

andybrucenet commented Mar 26, 2020

Platform: OSX Catalina

$ sw_vers -productVersion
10.15.4

$ java -version
openjdk version "14" 2020-03-17
OpenJDK Runtime Environment (build 14+36-1461)
OpenJDK 64-Bit Server VM (build 14+36-1461, mixed mode, sharing)

Problem:

 $ /Applications/GanttProject.app/Contents/MacOS/JavaAppLauncher
2020-03-26 11:39:33.270 JavaAppLauncher[16987:304952] NSString *findJavaDylib(NSString *, _Bool, _Bool, _Bool, _Bool) Searching for a JRE.
2020-03-26 11:39:33.271 JavaAppLauncher[16987:304952] NSString *findJREDylib(int, _Bool, _Bool) JRE search exception: 'launch path not accessible'
2020-03-26 11:39:33.340 JavaAppLauncher[16987:304952] int launch(char *, int, char **) Launchpath: /Library/Java/JavaVirtualMachines/openjdk-14.jdk/Contents/Home/lib/jli/libjli.dylib
2020-03-26 11:39:33.343 JavaAppLauncher[16987:304952] int launch(char *, int, char **) Error launching JVM Runtime ((null)) Relative Path: '/Library/Java/JavaVirtualMachines/openjdk-14.jdk/Contents/Home' (dylib: /Library/Java/JavaVirtualMachines/openjdk-14.jdk/Contents/Home/lib/jli/libjli.dylib)
  error: Unable to load Java Runtime Environment.

Let's check that folder.

$ sudo ls -la /Library/Java/JavaVirtualMachines/openjdk-14.jdk/Contents/Home/bin/jli
ls: /Library/Java/JavaVirtualMachines/openjdk-14.jdk/Contents/Home/bin/jli: No such file or directory

Hmm. Folder not there. Where could this dynamic library be?

$ sudo find /Library/Java/ -name libjli.dylib
/Library/Java//JavaVirtualMachines/openjdk-14.jdk/Contents/Home/lib/libjli.dylib
/Library/Java//JavaVirtualMachines/openjdk-14.jdk/Contents/MacOS/libjli.dylib

Ah. Folder naming is slightly different from what JavaAppLauncher expects.

Solution:

$ sudo ln -fs \
  /Library/Java/JavaVirtualMachines/openjdk-14.jdk/Contents/Home/lib \
  /Library/Java/JavaVirtualMachines/openjdk-14.jdk/Contents/Home/lib/jli

Everything works and we are all happy:

$ /Applications/GanttProject.app/Contents/MacOS/JavaAppLauncher
2020-03-26 11:59:37.779 JavaAppLauncher[17070:314706] NSString *findJavaDylib(NSString *, _Bool, _Bool, _Bool, _Bool) Searching for a JRE.
2020-03-26 11:59:37.779 JavaAppLauncher[17070:314706] NSString *findJREDylib(int, _Bool, _Bool) JRE search exception: 'launch path not accessible'
2020-03-26 11:59:37.849 JavaAppLauncher[17070:314706] int launch(char *, int, char **) Launchpath: /Library/Java/JavaVirtualMachines/openjdk-14.jdk/Contents/Home/lib/jli/libjli.dylib
2020-03-26 11:59:37.884 JavaAppLauncher[17070:314725] NSString *findJavaDylib(NSString *, _Bool, _Bool, _Bool, _Bool) Searching for a JRE.
2020-03-26 11:59:37.884 JavaAppLauncher[17070:314725] NSString *findJREDylib(int, _Bool, _Bool) JRE search exception: 'launch path not accessible'
2020-03-26 11:59:37.953 JavaAppLauncher[17070:314725] int launch(char *, int, char **) Launchpath: /Library/Java/JavaVirtualMachines/openjdk-14.jdk/Contents/Home/lib/jli/libjli.dylib
Writing log to /Users/l.abruce/ganttproject.log

That is all.

@Thrameos
Copy link
Contributor

If you have a fix to the JVMFinder to locate the correct shared library it would be great. Unfortunately I don't have access to a Mac.

@andybrucenet
Copy link

andybrucenet commented Mar 26, 2020

Hey @Thrameos there are some warnings - they don't block anything so no worries.

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.itextpdf.text.pdf.MappedRandomAccessFile$1 (file:/Applications/GanttProject.app/Contents/Java/plugins-2.8.10/org.ganttproject.impex.htmlpdf/lib/itextpdf-5.3.1.jar) to method java.nio.DirectByteBuffer.cleaner()
WARNING: Please consider reporting this to the maintainers of com.itextpdf.text.pdf.MappedRandomAccessFile$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

Don't think this is Mac issue. Maybe from me using using latest Java?
Just FYI...

Whoops - this is for GanttProject and I was just pasting away merrily. I'll open it there :)

@Thrameos
Copy link
Contributor

I have seen that on a number of projects including maven. I believe this this is an issue with the jar org.ganttproject.impex.htmlpdf. I don't believe it is related to JPype directly. I think that some libraries are using reflection to access a private field which is now being deprecated. We do not currently make access to DirectBuffer.cleaner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants