Add libjvm.so to LD_LIBRARY_PATH
See original GitHub issueI’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:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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.