Export to Runnable jar with additional built-in code libraries in eclipse

I am having trouble exporting my java project from eclipse as a jar executable. My Java project uses an external library (called jri). I exported the jri.jar file and set the library path for my native library in eclipse and it works great in development in eclipse. However, when I export it as a jar executable, 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 placed a folder called lib in the same directory as my project jar; this lib folder contains the jri native library. jri native library is not in one file, but in a folder. This is the same setup as in eclipse.

How do I export my project to eclipse,

 Export... Java > Runnable JAR file Copy required libraries into a sub folder next to the generated Jar Finish 

And my folder is organized this way

 folder project project.jar project_lib jri.jar jri native library folder 

MANIFEST.MF of my project.jar:

 Manifest-Version: 1.0 Class-Path: . project_lib/jri.jar Main-Class: index 

What I want to achieve is to give the other person a folder, including project.jar, and all that is needed so that he / she can run it without having to install anything else. Many thanks

+9
java eclipse jar jri
source share
4 answers

Add a script containing something like this:

 #!/bin/bash java -Djava.library.path=project_lib/native/ -jar project_lib/jri.jar 

I export some Java projects this way.

+8
source share

It is quite difficult to implement. The solutions I've seen include extracting your own libraries in the JAR into the temp OS directory, and then loading it. I would go for a complete solution for this. One Jar and Java Class Loader support it, and on the second page you will find links to similar tools.

+3
source share

You can put the libraries inside in your jar:

Export...

Java> Downloadable JAR file

Required libraries for packages in the created bank

Done

I always export this way. I don't know if this will work in your case, but it's worth a try.


Edit:

See these links:

My guess is that this is incorrectly associated with LD_LIBRARY_PATH. Or the file he is looking for is not listed in the specified path.

+1
source share

You know that I had similar problems.

 Could not extract native JNI library. 

all of the above suggestions cannot help me. I could not stop and start deamon gradle using the following command:

 gradle --stop 

I saw that deamon gradle is still not stopped in my processes. That's why I kill him in my process, and everything will be fine :)

0
source share

All Articles