I want to pack jar file without containing depedency jar libraries using eclipse IDE. I used these steps to pack but the result jar file always contains jar libraries.
Some steps I did
Jar file I want to pack is jar library not runable jar file
Thanks
In eclipse, when you are creating a jar file, select option named 'JAR file' and not 'Runnable JAR'. When you click on next, you will get a list of items which you need to include while creating your jar file with a check box in front of each item. Just don't select the items you don't want to export (in your case dependent libraries).
Hope this helps.
Under Export, click Jar file and not Runnable Jar file
I would use an ant task...
<zip destfile="${backupJar}" update="true" basedir="${basedir}/../../"
includes="**/*.xml*, **/*.java"
compress="true"/>
Remember that a jar is really a zip file with a different extension.
See
http://ant.apache.org/manual/Tasks/zip.html
EDIT: you specifically asked how to ignore dependencies. This is achieved by using the excludes attribute of the zip task, for example:
<zip destfile="${backupJar}" update="true" basedir="${remotedir}/../"
excludes="**/lib/testonly.zip,
**/lib/ms*.jar,
**/*.tmp"
includes="exported/**/*.*, exported/jf123/**/*.*" compress="true"/>
Related
I know how to make an executable Jar file in Eclipse.
but if I want to add *.java files in the jar file,
(when I want to CREATE a jar file),
are there any good ways?
or do I need to add them after Eclipse creates a jar file?
I have a Project in Eclipse and I want to use a library. When I debug this Project, it works. But when I export it, the JAR is not included, and I get a ClassNotFoundException.
How can I export a Project, and include another (JAR-) File. It isn't a runnable JAR file. I already tried to copy the library in my project, doesn't work.
You need to use FatJar plugin in Eclipse to pack all your libraries into one jar file, as your dependencies are present in a seperate jar file.
Eclipse is able to unpack the JAR and pack it into the generated one. Choose one option at in the export frame (File → Export → Runnable JAR File):
:
I have a library called Snakeyaml.jar, and I want to add it to my eclipse project, so it will be included in my jar, when I export my project. So far, I only see ways to add an "External Jar" which only adds a jar library to the buildpath, and does NOT include it in the program when being exported! How can I do it, and do I need any plugins for that? Please help!
Thanks.
Adding the jar to your build path is for compilation and runtime, but from eclipse only. A common misconception is that jar files can be added into other jar files, which will never work. What you probably want is extract your library jar into your exported jar. To achieve this:
File - Export
Expand Java node and select Runnable JAR File
In the library handling section, select Extract required libraries into generated JAR
Reference:
http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Freference%2Fref-export-runnable-jar.htm
While exporting you can chose the File->Export->Runnable Jar Option . Then use the selection like below screen i.e Extract required libraries into generated jar
Okay, so I understand what you are actually asking! You want the Snakeyaml.jar file inside of your exported jar file, and for your program to use its libraries.
To do so, drag and drop the Snakeyaml.jar file into your src folder in eclipse.
Then, go to build path, and instead of looking for external jars for your buildpath, choose to use the jar file that is already in your src folder in eclipse. Once you do that, you should export it and pick to "Extract required libraries into jar file" or something like that, and everything should work well! You will notice upon opening the exported jar file with a tool like Winrar, that the jar you had in your src folder is not there, but the packages of the jar are actually side by side with yours.
I want to create a jar file of my project which is internally using some other external jars.
Basically what I am expecting is a single jar file which has all the class files and external files in it.
can someone help me in this
If your classes use external jar files then you need to enclose those jars into your jar file.
Right click on the project in eclipse then :
Click on 'export'->'Runnable Jar`
Here: Make sure you select 'Extract required libraries into generated JAR'
This will extract all the libraries present on the classpath of your project. into the exported jar file
i have created a java application which uses data from its config folder and , it also uses third party jar files those are located in lib folder, could anyone tell me how to create jar file for this project with the content stored in config file and lib folder.
i tried creating jar using eclipse export functionality. when i run this jar file, it says it can not find the third party libraries that i have used for this project and configuration file.
thanks in advance for any help
You can create a Runnable JAR in Eclipse 3.4+ in the Export wizard selection dialog (right click on a project and go to Export...) using an existing launch configuration which will incorporate the libraries or repack them. Config files should be readable from the same directory as the runnable jar is located. If you need any help with loading these in, just ask :)
(source: eclipse.org)
You have two options
include the stuff in the third-party jars in your jar
provide access to the jars on the classpath when you run your jar.
Both have their benefits and their drawbacks.
Java does not support putting JAR files inside executable JAR files, so you can't just put your third-party library JAR files inside your own JAR - Java won't be able to find them.
If you don't want to distribute your application as a whole bunch of JAR files, you can use a look such as One-JAR which will build a JAR file for you that contains your own classes plus the classes of the third-party libraries that you're using.
To learn more about how to package a program in an executable JAR file, see Packaging Programs in JAR Files in Sun's Java Tutorials.
If you use netbeans just by click on "build" a jar file will show up in the "dist" file in your project directory