简体   繁体   中英

creating jar file for java application

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

  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.

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.

如果仅使用netbeans单击“build”,jar文件将显示在项目目录的“dist”文件中

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM