hardwarelayer / tientn-jboard-game

A world conquer game based on TripleA with more territory building feature, language support, and special language learning feature. Check branch feature-tientn-j-lang
GNU General Public License v3.0
0 stars 0 forks source link

(solved) JavaNativeFoundation: GetGlobalVM: Failed to locate @rpath/libjvm.dylib for JNI_GetCreatedJavaVMs(). A JVM must be loaded before calling this function. #3

Open hardwarelayer opened 3 years ago

hardwarelayer commented 3 years ago

MacOS BigSur: A lot of log like the title

hardwarelayer commented 3 years ago

While trying to locate the libjvm.dylib, in BigSur I only found: /Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/MacOS/libjli.dylib /Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home/jre/lib/server/libjvm.dylib

Check this issue: https://github.com/CoatiSoftware/Sourcetrail/issues/757 I can found it here: /Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home/lib/server/libjvm.dylib try to link: sudo ln -s /Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home/lib/server/libjvm.dylib /Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/MacOS/libjvm.dylib -> but the application still complain same message

% cd /Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home
% sudo ln -s /Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home/lib/server/libjvm.dylib /Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/MacOS/libjvm.dylib
% sudo mkdir -p jre/lib/server/
% sudo ln -s /Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home/lib/server/libjvm.dylib /Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home/jre/lib/server/libjvm.dylib

-> but the application still complain same message

Check again with this newer issue: https://github.com/Homebrew/homebrew-core/issues/66953

% cd /Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home/lib/server/
% otool -L libjvm.dylib 

libjvm.dylib: @rpath/libjvm.dylib (compatibility version 1.0.0, current version 1.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5) /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)

Found another related folder: /usr/local/opt/openjdk/libexec/openjdk.jdk/Contents/Home/lib/

% sudo ln -s /Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home/lib/server/libjvm.dylib /usr/local/opt/openjdk/libexec/openjdk.jdk/Contents/Home/lib/

Exec app: #

A fatal error has been detected by the Java Runtime Environment:

#
#  SIGSEGV (0xb) at pc=0x0000000113b8e778, pid=5629, tid=7683
#
# JRE version:  (14.0.1+14) (build )
# Java VM: OpenJDK 64-Bit Server VM (14.0.1+14, mixed mode, sharing, tiered, compressed oops, g1 gc, bsd-amd64)
# Problematic frame:
# C  [libjvm.dylib+0x546778]  JVM_FindClassFromCaller+0x58
#

-> so at least, we know the JVM load library from this folder: /usr/local/opt/openjdk/libexec/openjdk.jdk/Contents/Home/lib/
hardwarelayer commented 3 years ago

it seems the libjvm.dylib is not working in MacOS BigSur ... so it cause error when I put it in the correct folder above

May be ... no way? https://stackoverflow.com/questions/7118750/failed-to-locate-method-jni-getcreatedjavavms-in-the-libjvm-dylib-mac-os/7160476

hardwarelayer commented 3 years ago

I found another thing:

inside /usr/local/opt/openjdk/libexec/openjdk.jdk/Contents/Home/lib/ there's a "server" folder which contains the libjvm.dylib

% ll /usr/local/opt/openjdk/libexec/openjdk.jdk/Contents/Home/lib/server/libjvm.dylib 14436256 Sep 30 2020 /usr/local/opt/openjdk/libexec/openjdk.jdk/Contents/Home/lib/server/libjvm.dylib

And it's different from this file: % ll /Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home/lib/server/libjvm.dylib 16324496 Aug 12 2020 /Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home/lib/server/libjvm.dylib

So I tried: % sudo ln -s /usr/local/opt/openjdk/libexec/openjdk.jdk/Contents/Home/lib/server/libjvm.dylib /usr/local/opt/openjdk/libexec/openjdk.jdk/Contents/Home/lib/libjvm.dylib

And now it's working! :D

rajaravivarman commented 3 years ago

I found another thing:

inside /usr/local/opt/openjdk/libexec/openjdk.jdk/Contents/Home/lib/ there's a "server" folder which contains the libjvm.dylib

% ll /usr/local/opt/openjdk/libexec/openjdk.jdk/Contents/Home/lib/server/libjvm.dylib 14436256 Sep 30 2020 /usr/local/opt/openjdk/libexec/openjdk.jdk/Contents/Home/lib/server/libjvm.dylib

And it's different from this file: % ll /Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home/lib/server/libjvm.dylib 16324496 Aug 12 2020 /Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home/lib/server/libjvm.dylib

So I tried: % sudo ln -s /usr/local/opt/openjdk/libexec/openjdk.jdk/Contents/Home/lib/server/libjvm.dylib /usr/local/opt/openjdk/libexec/openjdk.jdk/Contents/Home/lib/libjvm.dylib

And now it's working! :D

@hardwarelayer Thanks a lot 👍 This worked for me.