10.07.2015 Views

Download - Multivac!

Download - Multivac!

Download - Multivac!

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2.5 Java BindingJava supports a portable mechanism for attaching native language code to Java programs,the Java Native Interface (JNI). The JNI provides programming conventions forcalling native C or C++ routines from within Java code, and vice versa. Each C routinehas to be wrapped with the appropriate code in order to be available to the Java VM, andthe resulting library has to be generated as a shared or dynamic object in order to beloaded into the Java VM.PDFlib supplies JNI wrapper code for using the library from Java. This technique allowsus to attach PDFlib to Java by loading the shared library from the Java VM. The actualloading of the library is accomplished via a static member function in the pdflibJava class. Therefore, the Java client doesn’t have to bother with the specifics of sharedlibrary handling.Taking into account PDFlib’s stability and maturity, attaching the native PDFlib libraryto the Java VM doesn’t impose any stability or security restrictions on your Javaapplication, while at the same time offering the performance benefits of a native implementation.Regarding portability remember that PDFlib is available for all platformswhere there is a Java VM!Installing the PDFlib Java Edition. For the PDFlib binding to work, the Java VM musthave access to the PDFlib Java wrapper and the PDFlib Java package. PDFlib is organizedas a Java package with the following package name:com.pdflib.pdflibThis package is available in the pdflib.jar file and contains a single class called pdflib. Usingthe source files provided in the PDFlib Lite distribution you can generate an abbreviatedHTML version of the PDFlib Reference using the javadoc utility since the PDFlibclass contains the necessary javadoc comments. Comments and restrictions for usingPDFlib with specific Java environments may be found in text files in the distributionset.In order to supply this package to your application, you must add pdflib.jar to yourCLASSPATH environment variable, add the option -classpath pdflib.jar in your calls to theJava compiler and runtime, or perform equivalent steps in your Java IDE. In the JDK youcan configure the Java VM to search for native libraries in a given directory by settingthe java.library.path property to the name of the directory, e.g.java -Djava.library.path=. pdfclockYou can check the value of this property as follows:System.out.println(System.getProperty("java.library.path"));In addition, the following platform-dependent steps must be performed:> Unix: the library libpdf_java.so (on Mac OS X: libpdf_java.jnilib) must be placed in oneof the default locations for shared libraries, or in an appropriately configured directory.> Windows: the library pdf_java.dll must be placed in the Windows system directory, ora directory which is listed in the PATH environment variable.2.5 Java Binding 31

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!