How to Use PDFNet with JRuby?

How do I use PDFNet library with JRuby?


In order for JRuby to find the native PDFNetC library (PDFNetC.dll,, libPDFNetC.dylib), it must be placed at the correct locations:


  • Any of the directories specified in PATH environment variable.

  • Inside %WINDIR%\System32

  • In /usr/lib or its derivatives (i.e. /usr/local/lib)

  • Any of the directories specified in LD_LIBRARY_PATH environment variable.

  • Copy libPDFNetC.dylib to /Library/Java/Extensions/libPDFNetC.jnilib.
    In addition to any of the above, an alternative way of specifying where the native library resides is by adding -J-Djava.library.path option to jruby (of course, this will only work when running from command line interface).

The file PDFNet.jar must also be placed in the lib folder of JRuby.

When using PDFNet with JRuby, it is also important to keep in mind that JRuby loads the Java API instead of the Ruby API. PDFNet’s Ruby API is based on the C++ API and is using PascalCase for methods names, where as the Java API is using camelCase for method names.

PDFNet.Initialize(“ABC”) # PascalCase, works for Ruby but not for JRuby

PDFNet.initialize(“ABC”) # camelCase, works for JRuby but not for Ruby