I have created a spring application which uses google or-tools. For that, I am importing jniortools using System.loadLibrary("jniortools"). when I provide the .dll file and run the war file it runs perfectly. But when I provide the .so file path in lib, I get the unsatisfiedlinkerror.
Taken from here, a solution for using or-tools over Intellij:
To make it work using Intellij (over a windows machine) you need to:
Install Microsoft Visual C++ Redistributable for Visual Studio
Download and extract the OR-Tools library for Java
In intellij, add jar dependency to the 2 jars under the lib folder of the extracted files (each of the 2 jars separately, do not add to lib folder itself. This is why).
Add the lib library path to VM options. In Intellij edit your run-configuration and add to vm options: -Djava.library.path=<path to the lib folder that hold the jars>
Load the jni library statically by adding the below code to your class (as mentioned here.)
static {
System.loadLibrary("jniortools");
}
Related
I am trying to communicate to Arduino with Java, so I'm using the rxtx library. I've downloaded the library and placed the respective files in my java project's folder. I put the rxtxxjar in a lib folder in the java project's folder, and I left the serial.jnlib straight into the java project's folder. I've taken the SerialTest code off of the arduino website, and I've tried to run it but I keep getting the UnsatisfiedLinkError. I've researched this question, and I've seen people saying basically the following in different ways:
Go to Project -> properties -> Java build path ->Find your .jar. Click
on + to open the JAR's properties. Select Native library location and
edit it to point to RXTX's shared library (.DLL, .so, .dylib).
However, I have no idea how to do the pointing to the shared library, especially since I don't see any .dll, .so, or .dylib file, and I cannot use the .jnlib because it is greyed out. Also on a smaller note, by my .jar is that just the project? I work in Eclipse Java EE.
You can use
System.load("Absolute path to your jni library");
This works fine on my project.
I'm using a .jar library that needs additional .dll or .so to function.
I copied them in a folder in my eclipse project and then added that folder to the native library location in Properties -> Java Build Path -> Libraries. When I start my application in eclipse, it works well but when I export it as a runnable jar and then execute it, it doesnt work anymore and gives me a java.lang.UnsatisfiedLinkError error.
Is there a possibility to add these additional files inside the .jar and also add them to the java.library.path variable when running the application?
Regards
I would suggest creating new resources folder in Eclipse (if you are using it, since that folder will be on classpath), or just add it manually to classpath.
I have created an application using the JFreeChart library for use on another machine.
Previously I have developed applications with JFreeChart (using the same libraries) which has worked fine on other machines. The only difference is this machine is running Vista.
Please see below for the run-time exception I am getting:
The class that cannot be found, however, is located in the highlighted jar in the below image showing my imported libraries for the JAR. I have also established that this JAR is included in the manifest for the application. See below image:
So I very much need this to work and have no idea where to look next - or what is causing this problem!
Development machine Java version:
1.7.0_45
Target machine Java version:
1.7.0_45
Thanks in advance.
Check the Class-Path attribute in your JAR's manifest, which should contain entries like this:
Class-Path: lib/jfreechart-1.0.17.jar lib/jcommon-1.0.21.jar …
Also, examine dist/README.TXT in your NetBeans project folder, which should say something like this regarding libraries required by your project:
To run the project from the command line, go to the dist folder and
type the following:
java -jar "CISOnlineMonitor.jar"
To distribute this project, zip up the dist folder (including the lib folder)
and distribute the ZIP file.
This has nothing to do with os i belive.You dont have all the necessery libs within your jar.Try to open a jar and see if you have them in.Fact that you are able to run it on your maschine only proves that.Make executable jar with eclipse or whathever you use.And when it ask you for libs check -Extract required libraries into generated Jar.
if you dont know how to get to that point
File>Export>Java>Runnable Jar File> Runnable JAR File Specification.
Also right click on your project and check Your build path.
RightClick project>Properties>Java Build Path>Libraries
Make sure you have everything correct
EDIT-
As i see you use NetBeans im not sure exactly how to find all this there.Bud it will be very similiar.
I want to add Selenum 2.21 libraries to Eclipse java project. I tried two methods.
One through Command line:
I have downloaded the Selenium 2.2(previously selenium RC) from their website for Java and unzipped them. When I write, java -jar (selenium-filename).jar, I am getting 'No main manifest attribute' error.
I know, the line mainclass has to be added in manifest file. There is no folder for the manifest in v2.21.
I also had Seleniumv1.03, which had the Manifest option. I added the line and a new line character, as mentioned in another post in someplace, but still I faced the issue.
two through copy/paste of jar files under JRE system library of the project:
This action is also not allowed. Cannot paste under JRE system library corresponding to the project.
Can you please tell a step by step procedure, other than refering somewhere in Sun tutorial, where they have given about java cfe (jar name) (class name) (class name.class), for defining the entry point... I had tried that too, at present...
For other reference, Java6 Update 32, I have downloaded for SDK and JRE. Firefox 12 and ie9, I am using. Eclipse Indigo IDE for Java Developers is been used.
what you have to do it download selinium jar file and save it in your project folder(Prefer if you have a lib floder)
Then right click on project in project explorer. You can find build path option. Then click on it and it will show you configure build path option. Then you can add your library in to the project. Just show the path for selinium jar file.
I am having trouble exporting my java project from eclipse as a jar executable file. My java project uses an external library (its called jri). I have exported the jri.jar file and set the library path for its native library in eclipse, and it works great in development in eclipse. However, when I export it as an executable jar file I get the following error:
Cannot find JRI native library!
Please make sure that the JRI native library is in a directory listed in java.library.path.
I have placed a folder called lib in the same directory as my project's jar; this lib folder contains jri's native library. jri's native library is not in one file but in a folder. This is the same setup I have in eclipse.
The way I am exporting my project in eclipse is
Export...
Java > Runnable JAR file
Copy required libraries into a sub folder next to the generated Jar
Finish
And my folder is organized like this
folder project
project.jar
project_lib
jri.jar
jri native library folder
The MANIFEST.MF of my project.jar is:
Manifest-Version: 1.0
Class-Path: . project_lib/jri.jar
Main-Class: index
What I want to achieve is to give another person a folder including project.jar and anything else needed so she/he can run it without needing to install anything else.
Thanks so much
Add a script containing something like that:
#!/bin/bash
java -Djava.library.path=project_lib/native/ -jar project_lib/jri.jar
I export some java projects that way.
This is relatively hard to implement. The solutions I have seen involve extracting the native libraries in the JAR to an OS temp directory and then loading it. I would go for an integrated solution for that. One Jar and Java Class Loader support it, and on the second page you will find links to similar tools.
You can put the libraries inside your jar:
Export...
Java > Runnable JAR file
Package required libraries into generated Jar
Finish
I always export this way.
I don't know if it will work in your case, but worth a try.
Edit:
See these links:
Instalation, setup and setting environment properly
What to do when getting Cannot find JRI native library!
My guess is that this have something to do with LD_LIBRARY_PATH not correctly been set. Or the file wich it is searching for isn't in the path listed.
You know I had the similar problems
Could not extract native JNI library.
all above proposes can't help me. I couldn't stop and start gradle deamon by using follow command:
gradle --stop
I saw that gradle deamon still not stopped in my processes. That's why I kill it in my process and all will be fine :)