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
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
Related
I am having a problem when I try to use my Arduino in my java application when I export it to a runnable jar file. When I run the application on the IDE it runs just fine, the exported jar on the same machine too, but when I run it on a different machine I get a the
java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path.
I am sure that I have added the RXTXcomm.jar and the rxtxserial.dll to the build path as shown in the picture below build path
In the other machines where I put my jars, I copy mentioned two files in the exact same location but the error persists.
You have to copy the contents of the RXTXcomm.jar into the exported JAR-File.
Place the dlls into jre_home/bin/ or in your programs main folder.
I am developing a java app and I need to use jnativehook library. I have downloaded the .zip from https://code.google.com/p/jnativehook/downloads/list . There is a bin folder,src folder,build.xml,build.num and 3 .txt files when I extracted this folder.
I have included this library in my project by File -> project -> Java project from existing Ant file
And I have tried an example https://code.google.com/p/jnativehook/wiki/examples
But I get the following error
Exception in thread "main" java.lang.ExceptionInInitializerError
at GlobalKeyListenerExample.main(GlobalKeyListenerExample.java:25)
Caused by: java.lang.RuntimeException: Unable to locate the native library.
at org.jnativehook.GlobalScreen.loadNativeLibrary(GlobalScreen.java:462)
at org.jnativehook.GlobalScreen.<init>(GlobalScreen.java:71)
at org.jnativehook.GlobalScreen.<clinit>(GlobalScreen.java:53)
... 1 more
What location should I give in native library path?
Looking through the source of GlobalScreen.loadNativeLibrary(), it seems that you get this exception when the library has failed to find the DLL on the java.library.path and instead tries to unpack it from the JAR, only to fail to find it.
Some options for fixing this include:
Checking you are running a supported platform.
Extract the right DLL from the JAR and place it on the java.library.path.
To use this library, you only need to include the JAR in your project. I don't like the sound of this part of your question:
I have included this library in my project by File -> project -> Java project from existing Ant file
Just download JNativeHook-1.1.4.zip, extract the ZIP and add the JNativeHook.jar JAR to your project.
I am developing a GUI windows app in java.
I need to create an installer now. I got .jar file and now I am creating .exe file using Launch4j free s/w(I hope it is free s/w, Please let me know if it is paid one).
Project has many dependencies of external .jar files and .dll files.
I have included all jar files and dll files into Launch4j s/w when I run it getting the error as "Exception in thread "main" java.lang.UnsatisfiedLinkError: no jmtp in java.library.path"
Please help me how to create a perfect executable file.
Have edited my answer. Below is the working solution.
Add jar to yout project workspace. Here are the steps I followed in eclipse, to add DDL to project.
1.Create a folder under the project, for example dll. 2.Copy/paste all dll files into this folder. 3.In project -> Properties -> Java Build Path -> Source, click and expand the source details. 4.You will see Native library location, click on it. 5.Then click edit on the right, click workspace again. You can see the dll folder under the project. 6.Find it and click Ok. You will see the dll is added in the Native library location.
Post this do the following in run configuration. Say the dll you need is in Y:\path\to\dlls\lib. Then set your Run Configuration's working directory to Y:\path\to\dlls\ and set your VM arguments to include -Djava.library.path=lib
reference: Add .dll to java.library.path in Eclipse/PyDev Jython project
I've been given some jars generated by the Matlab JavaBuilder by some colleagues. Some work fine when I use them in my Eclipse project, but a new one fails with this error:
libmwblas: load error: mkl.dll
And a message about the dll not being found. When I look in the Matlab Compiler Runtime bin folder there is a mkl.dll in there.
Any suggestions as to why Matlab can't or won't see the dll?
Your JARs are using JNI and trying to resolve the required DLL.
Option one is to resolve this is by adding /bin folder you mentioned to your Windows PATH so that Java is able to resolve this (and probably some other) DLLs.
Another (cleaner for development purposes) option is to configure Eclipse by specifying Native library location for the JAR which attempts to load DLLs. Go to Java Build Path of your project, then find the appropriate JAR in Libraries tab, then expand it and set Native library location.
It export it fine as a Jar, but when I double click the project it won't load up.
I'm building a Java Slick2d game (my first). I've tried on both windows 7, and Ubuntu 12.10. Any suggestions?
If you run the exported jar file from the terminal, you'll see an Unsatisfied Link Error. To resolve this, you need to include the LWJGL natives. If you want everything in a self-contained jar, the easiest way is by using JarSplice.
Let's walk through how to do this step-by-step.
Open up JarSplice
Add the jar you exported from Eclipse.
Add the LWJGL natives. These can be downloaded from http://www.lwjgl.org/download.php. I'll be exporting for Linux, so I'm going to include the Linux native files. The native files should be in a folder called native.
Now specify the main class in your project. Don't forget to include the class's package.
Click Create Fat Jar and you're done! You can also export to a Linux .sh, Mac .app, or Windows .exe. Just make sure you include the appropriate natives.
Have fun sharing your game with others!
make sure you mention the Main Class: in META-INF
Detailed instructions
The detailed instructions for creating an executable JAR file for a stand-alone SWT file are listed below.
Create a runtime folder for the desired runtime target on your system (e.g., c:\swt\runtime-linux). Note that the target platform does not need to be the same as your development platform.
Find the correct SWT JAR file for the desired target platform. You can download the desired ZIP file from the SWT website. For example, for Eclipse 3.3 and a target platform of Linux, download the file swt-3.3.1.1-gtk-linux-x86.zip. Expand this ZIP file and copy the swt.jar file to the runtime folder. Remember that this swt.jar file is specific to one platform, in this case Linux.
3.Create a manifest file for your application using the Eclipse text editor (e.g., myapplication-manifest.txt). The text of the manifest should be as follows:
Manifest-Version: 1.0
Class-Path: swt.jar
Main-Class: mypackage.MyClassWithMainMethod
(blank line at end of file)
4.Make sure the manifest file ends with a blank line. Put the name of your package and class that contains the main() method for the Main-Class.
In Eclipse, select File/Export/Java/Jar file and press Next.
On the JAR File Specification dialog, select the source files for the classes you want in the application. In the export destination, browse to the runtime folder and enter in the desired name of the JAR file (e.g., myapplication.jar or myapplication_linux.jar). Press Next.
On the JAR Packaging Options dialog, make sure the "Export class files with compile warnings" box is checked. Otherwise, if your source files have any compile warnings, they will not be included in the JAR file. Press Next.
In the JAR Export dialog, select the option "Use existing manifest from workspace". Browse to the manifest file you created above. Press Finish.
If the JAR file already exists, you will be asked to overwrite it. Select Yes. If your project had any compile warnings, a message will display. If so, press OK.
At this point, the JAR file for your application has been created in the runtime directory.
If needed (i.e., your target platform is different than your development platform), copy the runtime directory to a directory on your target platform.
In your operating system's file explorer, browse to the runtime directory and run your JAR file. For example, in Windows, you can just double-click on it in the Windows File Explorer or, from the "cmd" prompt, you can enter the command: java -jar myapplication.jar. The application should run.
Find file "MANIFEST" in the jar file, and add line :
"Main-Class: {Your executable class name (the class with main method)}"