adding a jar to reference library - java

I have a jar file I could attach it to project reference library, but it does not have META-INF folder. Does attaching a jar by configuring build path still works?

If you are talking about Eclipse, yes, a .jar file without a META-INF folder works on the build path of a project. I just tried it.

Related

Java export jar including libraries

I have been looking around for some time now, but didn't a find way how to export a JAR (not runnable jar) that contains in it's build path the referenced libraries.
Using Eclipse, I have included the lib folder which contains the jars of the referenced libraries in the export process.
Importing that JAR to another project and calling some method results in a ClassNotFoundException.
Looking at the MANIFEST, I didn't see any reference to those jars in the classpath, though the jars are indeed included in the jar.
So my questions are:
1. Is there any way to accomplish the packaging of the non-executable JAR so it will include libraries?
2. Is there any best practice for building and deploying a jar that include other jars libraries?
I tried it too but it doesn't work for me. I added the final .jar file but it doesn't work.
So, I did a workaround.
Extract the .jar file that you want as a dependency.
Copy that content and put it all inside your .jar file.
Add your .jar file as dependency inside an eclipse project.
Run it and see if everything is ok.

How to add a jar to the classpath in eclipse

The program runs as it should in eclipse, however when I try running it as a Jar it throws a noClassDefFoundError.
I assume this is due to an imported jar (commons-io-2.4.jar) that does not get added to the classpath. Apparently I only need to add this jar to the lib folder. Problem is, I can't find this folder (in the workspace there are only .setting, bin and src, as well as a .classpath and a .project file) and I haven't found any options in the Projects properties that would solve this problem.
How do I do this in eclipse?
Add the jar in source dir or project folder then select in eclipse, right-click will give you to add the jar in classpath

JSPF is not loading lib of jar

I am using Java Simple Plugin Framework. I export a jar that has my plugin implementation. The implementation depends on a library, which I have as a jar. That jar gets exported within the lib directory of my jar, and added to the classpath of my jar.
But when I load my jar with JSPF, it fails with "NoClassDefFound" because it can't find the jar in the lib director of my jar.
My apologies if my approach off base; I just need to know how this is supposed to be done. How should I bundle my plugin implementation as a jar if it depends on another jar?
I used JSPF and achieved this requirement the following way:
place the library jar file in a folder called lib outside the plugin jar file. (So that
the lib folder and the plugin jar file is in the same folder). Then I added lib/"name_of_libjar" to the classpath entry in the manifest.mf file of the plugin jar file (Which should be inside the plugin jar files META-INF folder), and it worked fine for me.

Deploy Eclipse 4.1 Project

I have create a simple program using Eclipse 4.1.. I wanted to build or deploy my project into a .jar. I also added external libraries in my project. I wanted the output same as in Netbeans with the .jar file and lib folder in the dist folder, but there should be also a folder named help and lang.. How can I do this with eclipse?!
Follow the steps provided here.
Or if you don't want to complex things up, select Runnable JAR file instead of JAR file set the directory where the .jar is to be written then click Finish.
Eclipse will create the [Project Name]_lib directory for the external libraries included in the project.

binding class files in the jar file not generated by netbeans

When i clean and build my project using netbeans , though it makes the jar file of the project but it doesn't keep those files that i myself kept in the project folder. That includes some class files,a music file. What is the reason for this ? How do i do this ? I want to keep some class files not generated by the netbeans and also the music file.
What is the reason for this ? default Netbeans build.xml don't include other lib files.
If you look the dist folder you can see a lib folder too. This is your lib folder. If your lib files is in the classpath you jar run on every where if not your file look ./lib/*.jar
You can change your project to ant project or maven project and change your manifest and other files.

Categories

Resources