question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add libjvm.so to LD_LIBRARY_PATH

See original GitHub issue

I’m using this github action to setup Java for a non-java application that uses JNI and I’m getting the following error:

error while loading shared libraries: libjvm.so

Is it possible to (perhaps optionally) add this library to LD_LIBRARY_PATH? Additionally, on Windows it should be PATH.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
giltenecommented, Aug 31, 2020

You would do it in whatever way you instruct your users to do it. Most likely by e.g. adding (appending? pretending? depends on your requirement) $JAVA_HOME/lib/server/libjvm.so to LD_LIBRARY_PATH. Yes, the conventions for that relative path, and the name of the library, and the name of the variable to add it to can all vary by OS and potentially java version. But that’s life with native code (which will already be stringy dependent on all those same variables).

I can see some logic for asking for a helpful “have the action set an environment variable (like SETUP_JAVA_LIBJVM_LOCATION) that tells you where libjvm is” so that you can then use that in your later scripting to set something on the LD_LIBRARY_PATH (or equivalent). This would require the action to know where that location is for any JDK it downloads. It is possible to do, but there is no actual standard for this across java versions, OSs, or even JDK distributions (just some conventions that seem to be followed), and as binary download locations and APIs for locating JDKs in various distros currently don’t provide an answer to that question, it is likely to be fairly fragile.

1reaction
giltenecommented, Aug 31, 2020

Changing the LD_LIBRARY_PATH (or equivalent) in ways that don’t normally happen when pointing to a JDK seems to me to be the wrong thing generically, and can have seriously surprising side effects on existing applications (e.g. ones that would later switch JAVA_HOME to something else without changing LD_LIBRARY_PATH themselves, which is quite common).

It may be what yoyr specific application needs, but that application would have to have been doing that anyway to work in any normal environment where JAVA_HOME points to the JDK base and libjvm.so is not in the LD_LIBRARY_PATH. Most likely (IMO), your environment is setting LD_LIBRARY_PATH (from JAVA_HOME) too early, before the setup-java action was called. If I’m right, then moving whatever is setting that for you to happen after the setup-java action executes would be the way to go.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't find libjvm.so - java - Stack Overflow
I have tried the part with export LD_LIBRARY_PATH without success. The link to libjvm.so /usr/java/jre1.8.0_65/lib/amd64/server/libjvm.so The ...
Read more >
LD_LIBRARY_PATH and libjvm.so — oracle-tech
I'm trying to load the libjvm.so library explicitly during runtime so that I don't need to add the libjvm.so path to LD_LIBRARY_PATH ......
Read more >
Fix the libjvm.so file not found error - Anh Le's blog
We need to include the path towards libjvm.so (i.e. the Java library folder) in LD_LIBRARY_PATH, the environment variable that points Ubuntu ...
Read more >
JVM is ignoring LD_LIBRARY_PATH · Issue #457 - GitHub
The HotSpot JVM is ignoring LD_LIBRARY_PATH and expecting shared libraries to be one level up from where libjvm.so is loaded.
Read more >
How to add shared libraries to Linux's system library path
A typical solution is to write a wrapper shell script to set the LD_LIBRARY_PATH and then call that application. Well, I've discovered how...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found