简体   繁体   中英

Creating a Jar File which includes external jar libraries

I have written a java code using Jcreator that imports Jsoup libraries to execute. These libraries in .jar format. To do so, I went to Project Settings > Required libraries > Add > added the necessary libraries. Now, I created a jar file to include this class file and also the jar libraries. However, It wont run and gives an error that the Jsoup package is not found. Please help me with this issue. I have to include the jsoup libraries in to the jar file.

I have to include the jsoup libraries in to the jar file.

Hardly. Not only is your statement incorrect, but it could be illegal if it goes against the distribution rights of the libraries that you're using.

Just include the Jsoup jar files with your jar files not inside your jar files when distributing your application. Make sure that your jar file manifest file's class-path line refers to the proper location of the jsoup jar files relative to your jar files.

You should properbly be using an build tool like Maven to define your dependencies (the jars you need) and to build your software. See here for how to set up your project using maven: http://maven.apache.org/guides/getting-started/index.html

You cann then use the maven assembly-plugin to build a fat jar containing all needed jars (this might be ill advised as Hovercraft pointed out) or download all required jars for distribution with your project. See http://maven.apache.org/plugins/maven-assembly-plugin/ for details.

I do not know if jcreator supports maven. If not you should consider moving to a more popular IDE like eclipse or netBeans if possible. Both support maven out of the box (and are free).

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