I have made a utility java project which contains XML, DB and other such utility classes. This requires 3rd party dependencies on some of the Apache common libraries, so I have added it in my java project by configuring the build path in eclipse Juno. Now I want to export this java project as jar file. When I am exporting this project as runnable jar file, it is working fine i.e if I include this jar in some other java project, I am able to access the utility classes, but when I am simply exporting the utility project as jar, I am not able to use it. Runnable jar requires a main class, but I don't want to keep a main class in my utility java project. I have compared both the jar files. The difference that I found out was that in runnable jar file, there is no .classpath file but a simple jar file that is in there. In the runnable jar file, all the jar files are mentioned in file named MANIFEST-INF.mf file, but in simple jar file it contains only version of .mf file. Can anyone tell me how can I make a jar file without a main class and use it for my other java projects so that I just have to include the jar file and use it as it is.
Asked
Active
Viewed 933 times
0
-
Take a quick look at maven. Maybe it solves your problems. http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html – smsnheck Jun 30 '13 at 08:14
-
As a backup plan i am looking into maven too. but this is really simple thing that i should be able to do from eclipse itself isn't it?? do you mean to say that my above scenario is not possible throught eclipse?? – Mrunal Gosar Jun 30 '13 at 08:18
-
even this fellow has the same problem : http://stackoverflow.com/questions/16422892/how-to-export-a-jar-file-including-my-classes-and-other-jar-files-extracted-us?rq=1 but nobody has provided the solution through eclipse – Mrunal Gosar Jun 30 '13 at 08:22
-
I give up. I can't figure out what you actually want. – Stephen C Jun 30 '13 at 12:36
2 Answers
0
I assume it has not been provided in eclipse because extracting external 3rd party library classes in a utility project is something non-standard. It can result in a lot of problems as your project grows, class conflicts being one of them.
Still if you want to continue with your approach, yon can export your project as a normal jar project. Thereafter after open your project as well as the other third party libs in a utility like 7zip and drag-and-drop your third party library contents(except META-INF
) into your project jar. That's all.
If you however want to automate it, ant would be your friend.

Dhrubajyoti Gogoi
- 1,265
- 10
- 18
-
I was just wondering how apache commons or dom4j or log4j or any other jars.. how this jars are not executables and still people can include them in their project and use it???? – Mrunal Gosar Jul 03 '13 at 15:06
-
@MrunalGosar But these jars to do not include classes of external dependencies. If you just wanted to export your classes as a jar, this feature is already available. – Dhrubajyoti Gogoi Jul 03 '13 at 15:23