0

I have started a java project. I want to use a library which is called PDFnet. But It gives error. Where do I make wrong?

public class MainClass {
  public static void main(String[] args)
  { //System.out.println(System.getProperty("java.library.path"));
    //System.loadLibrary("C:\\Users\\BDagli\\Downloads\\PDFNetC64\\Lib\\PDFNet");
    boolean uninstallPrinterWhenDone = false; // change this to test the uninstallation functions
    PDFNet.initialize();

C:\Program Files\Java\jre7\bin;C:\WINDOWS\Sun\Java\bin;Files\Java\jdk1.7.0_71\bin;.....
Exception in thread "main" java.lang.UnsatisfiedLinkError: no PDFNetC in java.library.path
  at java.lang.ClassLoader.loadLibrary(Unknown Source)
  at java.lang.Runtime.loadLibrary0(Unknown Source)
  at java.lang.System.loadLibrary(Unknown Source)
  at pdftron.PDF.PDFNet.<clinit>(PDFNet.java:21)
  at com.pdf.net.MainClass.main(MainClass.java:19)
Burak Dağlı
  • 512
  • 2
  • 10
  • 33

3 Answers3

2

I wouldn't recommend putting any dll in the System32 folder (without a very good reason). At the very least you can end up using libraries you didn't intend to since System32 might be a higher priority folder for library loading. At the very least, use the PATH environment variable to specify the folder where PDFNetC.dll is.

However it is better to 'solve' the issue... If you look at the Java samples that come with PDFNet, you will see the following file in all the JAVA sample folders, RunText.bat which does the following.

@echo off
setlocal
set TEST_NAME=DigitalSignaturesTest
javac.exe -cp .;../../../Lib/PDFNet.jar *.java
java.exe -Djava.library.path=../../../Lib -classpath .;../../../Lib/PDFNet.jar %TEST_NAME%
endlocal

So you just need to set the java.library.path to the folder where PDFNetC.dll is in your IDE. I'm not sure how to set it in your IDE, but I'm sure it is easy to find.

Here is the fist link I found on google describing this variable better. http://www.coderanch.com/t/377174/java/java/java-library-path

Ryan
  • 2,473
  • 1
  • 11
  • 14
0

I am using Eclipse for IDE. Then I added. Are they enough? I don't have many experience

enter image description here

I SOLVED.

I put PDFNetC.dll into C:\Windows\System32

Burak Dağlı
  • 512
  • 2
  • 10
  • 33
0

In-case any folks using Eclipse come by this post, ensure your import of PDFNet.jar specifies the Native library location in Eclipse, like so:

Eclipse Java Build Path - Native library location

Where the directory I've specified in Native library location above contains the PDFNetC.dll (or PDFNetC.so for Linux, PDFNetC.dylib for Mac).

You can access the Java Build Path via:

enter image description here

CorreyL
  • 118
  • 1
  • 9