This tutorial will show you how to solve the Spring Tool Suite “Failed to load the JNI shared library” initialisation error.
The “Failed to load the JNI shared library” error is generally caused by two reasons:
Let’s explore the solutions for both cases.
JDK and STS come in two architectures, 32 and 64 bits, so the rule of thumb is to always run matching versions, either both of them being 32 bits (on 32 and 64 bits machines) or 64 bits (exclusive to 64 bits machines). Therefore, if the versions don’t match it is quite possible that your environment will not work as expected.
In order to check your Java version, run the following command which is going to print its version (64 bits in my case) at the last highlighted line:
C:\Users\bgasparotto>java -version java version "1.8.0_121" Java(TM) SE Runtime Environment (build 1.8.0_121-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
In regard to Spring Tool Suite’s version, just check which version you have downloaded from the website, but if you’re not sure, it usually follows a name pattern where the 64 bits version includes x86_64
as part of the file name, whilst the 32 bits doesn’t. In the image below, the first file is 32 bits and the second is 64:
Spring Tool Suite is a Eclipse based tool, so it has a STS.ini
file to setup its initialisation like Eclipse has its eclipse.ini
file. That said file resides in the same directory of the STS.exe
file and its default version looks like the following:
-startup plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar --launcher.library plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.550.v20170928-1359 -product org.springsource.sts.ide --launcher.defaultAction openFile -vmargs -Dosgi.requiredJavaVersion=1.8 --add-modules=ALL-SYSTEM -Xms40m -Dosgi.module.lock.timeout=10 -Xverify:none -Dorg.eclipse.swt.browser.IEVersion=10001 -Xmx1200m
As a result, it’s possible that the JRE path has been wrongly set in that file, specifying just the Java home folder instead of the Java executable javaw.exe
itself:
... -vm C:\Users\bgasparotto\Documents\Java\jdk1.8.0_121\bin -vmargs ...
In order to fix that, add the missing part as explained before:
... -vm C:\Users\bgasparotto\Documents\Java\jdk1.8.0_121\bin\javaw.exe -vmargs ...
Now, you should be good to go.
Please let me know if by any reason none of these solutions have worked for you, so I can help you fixing it =]
This guide will show you how to create a Python function decorator with a few…
This guide will show you how to fix the error Got permission denied while trying…
This guide will show you how to create a Python virtual environment on Intellij IDEA…
This tutorial will quickly show you how to to find and kill processes on Linux,…
This guide shows a possible solution for Python error Relocation R_X86_64_PC32 against symbol can not…
I condensed below a cheat sheet of Kubernetes useful commands. I will keep updating this…
View Comments
The second solution worked for me, thanks!
It worked on first try. Thanks for the article.
Thank you. It worked for me.
Grt !!! worked for me
Muito obrigado! Para mim resolveu, gratidão pela ajuda.
Hi
Checked both version as well as the java executable in ini..both are correct..still getting the error:
java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
no swt-pi4-gtk-4934r6 in java.library.path
no swt-pi4-gtk in java.library.path
Can't load library: /home/zeahmed/.swt/lib/linux/x86_64/libswt-pi4-gtk-4934r6.so
Can't load library: /home/zeahmed/.swt/lib/linux/x86_64/libswt-pi4-gtk.so
Thanks. It worked for me.
Fantastic !! It worked. Thanks
Wow. It worked for me too. Thank you so much.
after adding the vm field
Error : Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit