Bug 56676 - Normalize access to native library
Summary: Normalize access to native library
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 8.0.x-trunk
Hardware: All All
: P2 enhancement (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-26 22:20 UTC by Gael Lalire
Modified: 2018-06-28 11:17 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gael Lalire 2014-06-26 22:20:49 UTC
Docs seems to advice using $CATALINA_HOME/lib but you could also imagine $CATALINA_HOME/native directory.

What I wish is to avoid having a JVM launching with special options (java.library.path).
To achieve that you should use System.load and System.mapLibraryName instead of System.loadLibrary.

A code sample if $CATALINA_HOME/lib is the normalized native directory:
{code}
        File nativeLib = new File(System.getProperty("catalina.home"), "lib");
        for (int i = 0; i < NAMES.length; i++) {
            try {
                System.load(new File(nativeLib, System.mapLibraryName(NAMES[i])).getPath());
                loaded = true;
            }
{code}


It is useful if the tomcat instance is not running at JVM start but embedded and launched later.
Comment 1 Remy Maucherat 2018-06-28 11:17:25 UTC
Thanks for the suggestion, but I used bin/native for the default location. Implemented for 9.0.11. There are no backports plans at the moment.