Cannot load java shared library

JNI can’t find shared library after program has been deployed

I am having troubles after moving an exported Java project from the development machine to the production. The java project (an Eclipse plugin) has a JNI library written by me, which depends on a open source library, which in turn depends on Boost. I compiled everything, including Boost, on my SLES11 machine and the program just works. When I move the program to another machine, I get the error:

java.lang.UnsatisfiedLinkError:/path/to/project/lib/libMyJNI.so: libboost_system.so.1.67.0: cannot open shared object file: No such file or directory 

I copied the needed libraries in the same directory. ldd libMyJNI.so lists 20 dependencies but solves all of them. I still get the same error. I assume that java.library.path is correctly set, because it tries to load libMyJNI.so and recognize the dependencies. Am I right expecting that if ldd works, java should solve the dependencies? Any clue? Thank you! EDIT: here’s the output of ldd ldd libMyJNI.so

linux-vdso.so.1 => (0x00007fffa59ff000) libboost_system.so.1.67.0 (0x00007fc427bce000) libboost_filesystem.so.1.67.0 (0x00007fc4279b4000) libboost_thread.so.1.67.0 (0x00007fc42778f000) libboost_date_time.so.1.67.0 (0x00007fc42757a000) libboost_iostreams.so.1.67.0 (0x00007fc42735f000) libboost_serialization.so.1.67.0 (0x00007fc42710f000) libboost_chrono.so.1.67.0 (0x00007fc426f06000) libboost_atomic.so.1.67.0 (0x00007fc426d04000) libboost_regex.so.1.67.0 (0x00007fc426a00000) libpcl_common.so.1.8 (0x00007fc42673b000) libpcl_io.so.1.8 (0x00007fc4263cb000) libpcl_octree.so.1.8 (0x00007fc425fdc000) libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00007fc425c98000) libm.so.6 => /lib64/libm.so.6 (0x00007fc425a42000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fc42582b000) libc.so.6 => /lib64/libc.so.6 (0x00007fc4254cc000) librt.so.1 => /lib64/librt.so.1 (0x00007fc4252c3000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fc4250a6000) libz.so.1 => /lib64/libz.so.1 (0x00007fc424e8f000) libgomp.so.1 => /usr/lib64/libgomp.so.1 (0x00007fc424c86000) libpcl_io_ply.so.1.8 (0x00007fc424a21000) libpng12.so.0 => /usr/lib64/libpng12.so.0 (0x00007fc4247f9000) /lib64/ld-linux-x86-64.so.2 (0x00007fc427fe8000) 

Источник

Читайте также:  Check python script online

How to Fix ‘Failed to Load the JNI Shared Library’

Eclipse is an open source project which uses a Java plugin system to allow programmers programming in different languages to work together easily. It’s available for many platforms as well. The error mentioned in the title of the article is an error which appears after users try to open Eclipse on their Windows PC.

Eclipse usually just closes afterward. The problem often appears as soon as users install and run Eclipse. There have been many different methods used to resolve this problem and that is why we have gathered them in a single article for you to check out!

What Causes the ‘Failed to Load the JNI Shared Library’ Error?

The problem is often caused by one or two common issues which are shared among many users who have reported the problem online. Still, there are several ways to deal with the same problem. Check out the list below:

  • Mismatching versions of Eclipse and Java Runtime – Both programs must be either 64-bit or 32-bit or this error is bound to appear. Resolve the problem by switching both programs to the same format.
  • Both the 32-bit and 64-bit versions of Java installed – Eclipse might try to access the wrong one and you should guide it to the proper version by manipulating the Path variable.
  • Eclipse is unaware of the installation folder of Java – You should clarify the confusion by including it in the eclipse.ini file.

Solution 1: Edit the ‘eclipse.ini’ File

This specific problem can occur of the installation of Eclipse fails to understand just what the correct path to the executable might be. That can be resolved easily simply by adding a line inside the Eclipse configuration file available in the installation directory. Make sure you follow the instructions below in order to resolve the problem.

  1. Navigate to the folder’s location in the File Explorer simply by opening a folder and clicking This PC or My Computer from the left navigation pane or by searching for this entry in the Start menu.
Читайте также:  Убрать html теги excel

  1. In This PC or My Computer, double-click to open your Local Disk and navigate to the installation directory of Java Development Kit. After locating the Java folder, navigate to jrex.x.xx > bin and locate the ‘jawaw.exe’ file. Click the address bar and copy the full address to Clipboard. The ‘x.x.xx‘ placeholder represents the version of Java you have installed.

  1. Navigate to the Eclipse’s installation folder. The correct location can also be found after right-clicking the Eclipse shortcut and choosing the Open file location option from the context menu.
  2. Right-click the file called named ‘eclipse.ini’ and choose to open it with Notepad. Make sure you navigate to the top of the file and paste the lines below in order to resolve the problem. Make sure you also replace our placeholder address with the address you found out in the first part of the solution:
-vm C:\path\to\64bit\java\bin\javaw.exe
  1. Try running the program again and check to see if the ‘failed to load the JNI shared library’ error comes up.

Solution 2: Make Sure Eclipse and Java Versions Match

If you are using a 64-bit version of Eclipse, you should also make sure you install the 64-bit version of Java Runtime. The same goes for the 32-bit version. Make sure you follow the instructions below in order to uninstall the one and install the second option.

Uninstalling Java on Windows 10

  1. Click on the Start menu button located at the bottom left part of your screen. Select Settings by clicking on the gear icon above the Power button in Start menu.
  2. Select Apps section in the Settings app. Select Java from the list of installed apps and then click its Uninstall
  1. Respond to the instructions displayed on screen to complete the uninstall process.

Uninstalling Java on Previous Versions of Windows

  1. Click on the Start menu button located at the bottom left part of your screen.
  2. Select Control Panel from Start menu and switch the View by option to Category. Select Uninstall a Program under the Programs section.
  1. Select Java from the list of installed programs by clicking on it, and then click the Uninstall Follow the instructions on the screen to complete the wizard.

Installing Java

There are two ways of installing Java. You can either use the online installer which only downloads a small file which is used to download the entire program or you can download the entire package and install it without an active Internet connection. Here is how to install it offline:

  1. Go to the Manual download page and click on Windows Offline. Make sure you differentiate between Windows Offline which is the 32-bit version and Windows Offline (64-bit) which is obviously the 64-bit version.

  1. The File Download dialog box appears prompting you to run or save the download file Click Save to download the file to your local system.
  2. Close all applications including your browser and double-click on the saved file to start the installation process. Click the Install button to accept the license terms and to continue with the installation.

  1. Oracle has partnered with companies that offer various products. The installer may present you with an option to install these programs when you install Java. After ensuring that the desired programs are selected, click the Next button to continue the installation.
  2. A few brief dialogs confirm the last steps of the installation process; click Close on the last dialog. This will complete the Java installation process. Check to see if the problem still appears after you match the versions of Eclipse and Java Runtime.

Solution 3: Remove the Path Variable for Java

If you have both the 32-bit and the 64-bit version of Java installed on your computer, Eclipse may get confused trying to figure out which one to use. For example, if a 64-bit version of Eclipse tries to use the 32-bit version of Java, a problem will appear. This can be resolved without uninstalling one version of Java simply by deleting its Path variable. Make sure you follow the instructions below carefully.

  1. Right-click either on My Computer/This PC depending on the version of Windows you have installed on your computer and choose the Properties After that, locate the Advanced system settings button at the right side of the Properties window, click on it, and navigate to the Advanced tab.

  1. At the bottom right section of the Advanced tab, you will be able to see the Environment Variables option so click on it and you will be able to see a list of all user variables under the User variables section.

  1. Click the Path variable under System variables or the User variables section and click the Edit button below. Try to locate a path for the Java folder, select it and choose Delete from the left-side menu. This refers to the Java folder which doesn’t match the version of Eclipse.
  2. Try reopening the program and check to see if it will run properly now.

Источник

Problem to launch java at Debian: «error while loading shared libraries: libjli.so»

The executable you’re running looks for libraries in an rpath in addition to the normal library search path. The rpath here is $ORIGIN/../lib/i386/jli:$ORIGIN/../jre/lib/i386/jli . Normally $ORIGIN should be replaced by the location of the executable, here /usr/lib/jvm/java-6-openjdk/jre/bin .

Here, $ORIGIN isn’t being replaced. The feature is turned off in executables running with extra privileges (setuid, setgid, or setpcap), because otherwise you might be able to inject a different library and so run arbitrary code with elevated privileges. (See this article for a more detailed explanation.) The security issue was discovered relatively recently; in Debian it was fixed in DSA-2122-1, so before you upgraded to libc6-2.7-18lenny6 , your java executable would presumably have worked.

The symptom indicates that java is running with additional privileges. This is not the case in a normal Debian installation. Make sure that /usr/lib/jvm/java-6-openjdk/jre/bin/java is mode 755 and doesn’t have any capabilities ( getcap /usr/lib/jvm/java-6-openjdk/jre/bin/java , and setcap -r … to remove the capabilities if any).

(Original answer, which may be useful if you find that java works as root but not as other users, and it does turn out that you’re invoking different binaries.)

My bet is that you have some other java version earlier on your PATH ( sudo changes the PATH ). Check what type java says — it’s probably some different Java version for which ldd /path/to/bin/java reports libjli.so => not found .

And I speculate that the reason that this Java version can’t find libjli.so is that it’s looking for it through a rpath (library search path stored in the executable) that doesn’t match the way it’s installed. If you have the java binary in /some/where/bin/java , and it has a relative rpath (which is the way of the Sun JDK and OpenJDK), the library should be in /some/where/lib/i386/jli/libjli.so (assuming an i386 architecture). If the rpath is absolute, you need to either put libjli.so in the exact specified location, or set LD_LIBRARY_PATH to include where libjli.so is.

Источник

Оцените статью