Zip Component, Email Component, Encryption Component ActiveX Control for Zip Compression .NET Components for ASP.NET
ActiveX and .NET Components for Zip Compression, Encryption, Email, XML, S/MIME, HTML Email, Character Encoding, Digital Certificates, FTP, and more ASP Email ActiveX Component


Index of Chilkat Blog Posts

February 14, 2008

Java System.loadLibrary - Loading a Native DLL at Runtime

A Windows DLL (i.e. a Native Java Library, such as chilkat.dll) may be loaded at runtime by calling System.loadLibrary( dllFilename ), or System.load( dllFilePath ). For example:

    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
    }
	
    try {
        System.load("c:/temp/javaDeployTest/chilkat.dll");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
    }

With System.loadLibrary, you only specify the name of the DLL, such as "chilkat". The JVM (java runtime) will search for the DLL in the directories listed in java.library.path system property. This property may be set on the command line with the -D option:

java -Djava.library.path=c:\temp\myNativeDlls myTestApp
	
<strong>NOTE:</strong> There should be no SPACE character between the "-D" and the "java.library.path".
The lack of a SPACE character is correct.

The System.load method is more straightforward and allows you to specify the filepath of the native library directly.


Privacy Statement. Copyright 2000-2011 Chilkat Software, Inc. All rights reserved.
Send feedback to support@chilkatsoft.com

Components for Microsoft Windows XP, 2000, 2003 Server, Vista, Windows 7, and Windows 95/98/NT4.