1

I've been struggling for days to recognize what is going on with my current Java Maven project that uses Tomcat and external libraries (JCo). For some reason, the System.getProperty("java.library.path") result does not match the paths from my enviroment variable %PATH% (default). I do NOT intend to change the java.library.path value or whatsoever, I just want to know why it is NOT DEFAULTING to the %PATH% variable.

Here's how I identified it:

public static void main(String[] args) {
    for (String path : System.getProperty("java.library.path")) {
        System.out.println(path);
    }
}

The above snippet results in:

C:\Program Files\Java\jre1.8.0_131\bin C:\WINDOWS\Sun\Java\bin C:\WINDOWS\system32 C:\WINDOWS C:/Program Files/Java/jre1.8.0_131/bin/server C:/Program Files/Java/jre1.8.0_131/bin C:/Program Files/Java/jre1.8.0_131/lib/amd64 C:\ProgramData\Oracle\Java\javapath C:\Program Files\Docker\Docker\Resources\bin C:\Python27 C:\Python27\Scripts C:Program Files\Git\bin C:Program Files\Git\cmd \C:\Program Files (x86)\Intel\iCLS Client\ C:\Program Files\Intel\iCLS Client\ C:\Windows\system32 C:\Windows C:\Windows\System32\Wbem C:\Windows\System32\WindowsPowerShell\v1.0\ C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL C:\Program Files\Intel\Intel(R) Management Engine Components\DAL C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT C:\Program Files\Intel\Intel(R) Management Engine Components\IPT C:\Users\Unknown\.dnx\bin C:\Program Files\Microsoft DNX\Dnvm\ C:\Program Files\Microsoft SQL Server\120\Tools\Binn\ C:\Program Files\Microsoft SQL Server\130\Tools\Binn\ C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\ C:\Program Files (x86)\Microsoft Emulator Manager\1.0\ C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\ C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\ C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ C:\Program Files\Git\cmd C:\Program Files (x86)\nodejs\ C:\WINDOWS\system32 C:\WINDOWS C:\WINDOWS\System32\Wbem C:\WINDOWS\System32\WindowsPowerShell\v1.0\ C:\Program Files (x86)\Skype\Phone\ C:\Program Files\Java\jdk1.8.0_112\bin D:\Arquivos de Programas\Apache Software Foundation\Maven 3.3.9\bin C:\Pro C:\Users\Unknown\AppData\Roaming\npm C:\Users\Unknown\AppData\Local\Microsoft\WindowsApps C:\Program Files\Eclipse Neon .

...while the echo %PATH% produces the following results:

C:\Program Files\Docker\Docker\Resources\bin C:\Python27 C:\Python27\Scripts C:\WEEEEEEEEEEEIRD\PAAAAAAAATHHHHHH\FOR MAVEN EXAMPLE C:Program Files\Git\bin C:Program Files\Git\cmd \C:\Program Files (x86)\Intel\iCLS Client\ C:\Program Files\Intel\iCLS Client\ C:\Windows\system32 C:\Windows C:\Windows\System32\Wbem C:\Windows\System32\WindowsPowerShell\v1.0\ C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL C:\Program Files\Intel\Intel(R) Management Engine Components\DAL C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT C:\Program Files\Intel\Intel(R) Management Engine Components\IPT C:\Users\Unknown\.dnx\bin C:\Program Files\Microsoft DNX\Dnvm\ C:\Program Files\Microsoft SQL Server\120\Tools\Binn\ C:\Program Files\Microsoft SQL Server\130\Tools\Binn\ C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\ C:\Program Files (x86)\Microsoft Emulator Manager\1.0\ C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\ C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\ C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ C:\Program Files\Git\cmd C:\Program Files (x86)\nodejs\ C:\WINDOWS\system32 C:\WINDOWS C:\WINDOWS\System32\Wbem C:\WINDOWS\System32\WindowsPowerShell\v1.0\ C:\Program Files (x86)\Skype\Phone\ C:\Program Files\Java\jdk1.8.0_112\bin D:\Arquivos de Programas\Apache Software Foundation\Maven 3.3.9\bin D:\Arquivos de Programas\SAP\JCo C:\Program Files (x86)\Intel\iCLS Client\ C:\Program Files\Intel\iCLS Client\ C:\Windows\system32 C:\Windows C:\Windows\System32\Wbem C:\Windows\System32\WindowsPowerShell\v1.0\ C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL C:\Program Files\Intel\Intel(R) Management Engine Components\DAL C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT C:\Program Files\Intel\Intel(R) Management Engine Components\IPT C:\Users\Unknown\.dnx\bin C:\Program Files\Microsoft DNX\Dnvm\ C:\Program Files\Microsoft SQL Server\120\Tools\Binn\ C:\Program Files\Microsoft SQL Server\130\Tools\Binn\ C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\ C:\Program Files (x86)\Microsoft Emulator Manager\1.0\ C:\Program Files (x86)\nodejs\ C:\Program Files (x86)\Skype\Phone\ C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\ C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\ C:\Pro C:\Users\Unknown\AppData\Roaming\npm C:\Users\Unknown\AppData\Local\Microsoft\WindowsApps

As we can see, the "C:\WEEEEEEEEEEEIRD\PAAAAAAAATHHHHHH\FOR MAVEN EXAMPLE" from %PATH% does not show in the java.library.path. This path contains the required DLL for my project.

What could be wrong? Thanks a lot in advance!

I'm using:

  • Windows 10 x64
  • Maven 3.3.9
  • Tomcat 9
  • Java 8
  • Eclipse Neon
  • JCo 3 (SAP Java Connector)
  • Hibersap 1.3.0 (JCo "wrapper")

Pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>br.com.nooder</groupId>
    <artifactId>Hibersap</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>Hibersap</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.hibersap</groupId>
            <artifactId>hibersap-core</artifactId>
            <version>1.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.hibersap</groupId>
            <artifactId>hibersap-jco</artifactId>
            <version>1.3.0</version>
        </dependency>
        <!-- mvn install:install-file -DgroupId=org.hibersap -DartifactId=com.sap.conn.jco.sapjco3 -Dversion=3.0.16 -Dpackaging=jar -Dfile="C:\somewhere\sapjco3.jar" -->
        <dependency>
            <groupId>org.hibersap</groupId>
            <artifactId>com.sap.conn.jco.sapjco3</artifactId>
            <version>3.0.16</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!--
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <systemPropertyVariables>
                        <propertyName>java.library.path</propertyName>
                        <buildDirectory>D:\Arquivos de Programas\SAP\JCo</buildDirectory>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
            -->
        </plugins>
    </build>
</project>
Yves Calaci
  • 1,019
  • 1
  • 11
  • 37
  • Possible duplicate of [Can I find out what variable java.library.path maps to on the current platform?](http://stackoverflow.com/questions/9551588/can-i-find-out-what-variable-java-library-path-maps-to-on-the-current-platform) – Arnaud May 04 '17 at 13:06
  • If you are doing this in any IDE, chances are that IDE is setting some environment variables upon startup. – Shailesh Pratapwar May 04 '17 at 13:07
  • @Berger your link helps just a single bit. One useful information I got from it is `java.library.path isn't guaranteed to be set from an environment variable at all`, although I want to know how is the `java.library.path` defaultly created – Yves Calaci May 04 '17 at 13:15
  • @YvesHenri : the point is that you can't rely on an environment variable to provide your expected library path , you should really customize the `-Djava.library.path` VM argument . – Arnaud May 04 '17 at 13:19
  • @Berger people say that `java.library.path` defaults to %PATH% on Windows enviroments. Is that false, then? This native lib my project requires is due to that JCo component (developed by SAP - sap.com). To keep my life easy, I dont want to relay on remembering to change anything, except adding the path to the lib to my %path% variable (if and only if `java.library.path` defaulted to %path%). Also, changing anything other than the previous example sounds like a trouble when working on this project with multiple developers. I'm sure there is a maven plugin or something that will solve it... – Yves Calaci May 04 '17 at 13:28

0 Answers0