From ad5635686cedfc4f59c46c8b624b2347c2581c8b Mon Sep 17 00:00:00 2001 From: Curtis Rueden Date: Tue, 10 Sep 2019 13:25:56 -0500 Subject: [PATCH 1/2] Link to libjli, not libjvm, on macOS When linking to Java on a macOS system without Apple Java 6 installed, an error is given when attempting to load Java via JNI: No Java runtime present, requesting install. And a dialog box appears saying "You need to install the legacy Java SE 6 runtime." Unfortunately, this is no longer possible on current versions of macOS. Linking to libjli sidesteps the issue, avoiding Apple's overzealous linkage check, while still allowing access to Java's native API. --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index ee9351e..29e777e 100644 --- a/setup.py +++ b/setup.py @@ -125,7 +125,7 @@ elif PLATFORM == 'darwin': ) )] else: - LIB_LOCATION = 'jre/lib/server/libjvm.dylib' + LIB_LOCATION = 'jre/lib/jli/libjli.dylib' # We want to favor Java installation declaring JAVA_HOME if getenv('JAVA_HOME'): @@ -136,7 +136,7 @@ elif PLATFORM == 'darwin': if not exists(FULL_LIB_LOCATION): # In that case, the Java version is very likely >=9. # So we need to modify the `libjvm.so` path. - LIB_LOCATION = 'lib/server/libjvm.dylib' + LIB_LOCATION = 'lib/jli/libjli.dylib' INCLUDE_DIRS = [ '{0}/include'.format(FRAMEWORK), From 9700c47cd44ba51b55c593d42a21c0b110ed3deb Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 16 Sep 2019 11:03:32 -0400 Subject: [PATCH 2/2] Add support for adoptopenjdk12 Signed-off-by: Curtis Rueden --- setup.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/setup.py b/setup.py index 29e777e..679447d 100644 --- a/setup.py +++ b/setup.py @@ -137,6 +137,12 @@ elif PLATFORM == 'darwin': # In that case, the Java version is very likely >=9. # So we need to modify the `libjvm.so` path. LIB_LOCATION = 'lib/jli/libjli.dylib' + FULL_LIB_LOCATION = join(FRAMEWORK, LIB_LOCATION) + + if not exists(FULL_LIB_LOCATION): + # adoptopenjdk12 doesn't have the jli subfolder either + LIB_LOCATION = 'lib/libjli.dylib' + FULL_LIB_LOCATION = join(FRAMEWORK, LIB_LOCATION) INCLUDE_DIRS = [ '{0}/include'.format(FRAMEWORK),