1

I am using a Windows 10 OS and try to get JPBC (Pair-Based Cryptographie) running, as explained here: http://gas.dia.unisa.it/projects/jpbc/buildHowto.html#.WVlWQ4jyhhE . The installation worked well for the libraries and now I am having a bunch of folders, including .jar and .java files in my local maven repo .m2\repository\it\unisa\dia\gas. One of the files is jpbc-pbc for instance but there are more

Now I imported a project from gradle that needs some of those files. This projects includes the line

System.loadLibrary("jpbc-pbc");

Now, this throws an error:

Could not load library jpbc-pbc. JCPABE will be extremely slow.
java.lang.UnsatisfiedLinkError: no jpbc-pbc in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at cpabe.Cpabe.<clinit>(Cpabe.java:24)
at cpabe.demo.DemoForCpabe.main(DemoForCpabe.java:63)

My path variable links to C:\Program Files\Java\jdk1.8.0_131 . Now whatever I try, putting the .jar into it or the src folder or both or whatever, I receive this error. What am I doing wrong?

Folder structure of jpbc-pbc is

jpbc-pbc
/2.0.0
//jpbc-pbc-2.0.0.jar
/src
//main (and so on)
//test (and so on)
/CMakeLists.txt
/FindGMP.cmake
/FindPBC.cmake
/maven-metadata-local.xml
/pom.xml
attr1bute
  • 21
  • 5
  • `loadLibrary()` is for loading `.dll` files, not `.jar` files. – Andreas Jul 02 '17 at 21:02
  • Why do they use it in their code and link it with a .jar file then? Is there an alternative for me? – attr1bute Jul 02 '17 at 21:09
  • Because the Java code requires the natively compiled code in the DLL file for executing high-performance encryption logic. That's what the warning *"JCPABE will be extremely slow"* is about. Without the fast native code, the encryption will be done using Java code, and that's a lot slower for something like that. – Andreas Jul 03 '17 at 04:26

1 Answers1

0

The jpbc-pbc library is not in your java.library.path. Try adding it using:

1. Command Line

java -Djava.library.path=<path_to_dll> <main_class>

2. Source Code

System.setProperty(“java.library.path”, “/path/to/library”);

3. IDE

Depends on the IDE you are using, for example in Eclipse you could:

  • Right-click on your project in the package explorer
  • Choose Build Path -> Configure Build Path
  • Add your library in the Libraries Tab
  • java -Djava.library.path= , but I only have got a .jar. I tried java -Djava.library.path=Desktop/jpbc-pbc/2.0.0 jpbc-pbc-2.0.0.jar now, but it says access denied, wherever I place it – attr1bute Jul 02 '17 at 21:32
  • @MarcBurian If you *only* have a `.jar` file, and no `.dll` file, then don't bother with the library path. The purpose of the library path is to specify one or more locations where `.dll` files are. You should however recheck where you got the `.jar` file, because it's very likely that the `.dll` file is there too. – Andreas Jul 03 '17 at 04:29
  • If you have a .jar file, you noeed to add it to the classpath and not the library path. – Ole Schaper Jul 05 '17 at 08:54
  • 1
    Method #2 does not work. At run time, the `java.library.path` property is "read-only" (sort of). While it is true that you can "set" the property and "get" the value you set from it, doing so does not actually change the `java.library.path` in the JVM. The JVM evaluates `java.library.path` sometime during its initialization, before program execution. So, unless you use [this hack](https://stackoverflow.com/questions/5419039/is-djava-library-path-equivalent-to-system-setpropertyjava-library-path) to force the JVM to reload the `java.library.path`, altering it at run time does not do anything. – Babak Feb 14 '18 at 22:04