views:

166

answers:

4

Hi all

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

A: 

If you use netbeans just by click on "build" a jar file will show up in the "dist" file in your project directory

Argiropoulos Stavros
The OP apparently uses Eclipse so this may not be of much help :-/
Péter Török
+2  A: 

You have two options

  1. include the stuff in the third-party jars in your jar
  2. provide access to the jars on the classpath when you run your jar.

Both have their benefits and their drawbacks.

glowcoder
+3  A: 

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 :)

alt text

Chris Dennett
yep, i need help since i have no much experience in this, i am trying your option , but it says , jar creation failed.
KItis
Does it give any more details or just that? Try going to Window > Show View > Error Log and see if you can find the details about the error :)
Chris Dennett
http://i39.tinypic.com/2h4ezh5.png this is the error massage i get,
KItis
thanx Chris, i got it working , you saved lot of my time today. so you are a hero for me :)
KItis
How did you fix it out of interest? It looks as if your project was out of sync or something and needed a refresh :)
Chris Dennett
A: 

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.

Jesper