3

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

asked May 11, 2010 at 14:23

4 Answers 4

4

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
(source: eclipse.org)

Glorfindel
22.8k13 gold badges97 silver badges124 bronze badges
answered May 11, 2010 at 14:34
Sign up to request clarification or add additional context in comments.

4 Comments

yep, i need help since i have no much experience in this, i am trying your option , but it says , jar creation failed.
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 :)
thanx Chris, i got it working , you saved lot of my time today. so you are a hero for me :)
How did you fix it out of interest? It looks as if your project was out of sync or something and needed a refresh :)
2

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.

Joachim Sauer
309k59 gold badges568 silver badges624 bronze badges
answered May 11, 2010 at 14:27

Comments

1

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.

answered May 11, 2010 at 14:51

Comments

0

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

answered May 11, 2010 at 14:26

1 Comment

The OP apparently uses Eclipse so this may not be of much help :-/

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.