Bug 56676

Summary: Normalize access to native library
Product: Tomcat 8 Reporter: Gael Lalire <gael.lalire>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: enhancement    
Priority: P2    
Version: 8.0.x-trunk   
Target Milestone: ----   
Hardware: All   
OS: All   

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.