Export a Java project without main method (with external jars) to Jar in Eclipse

不问归期 提交于 2020-01-14 12:59:13

问题


I have created a java project which only handles post and get request from a web api. I need to export it as jar file. The issue is I'm using external jar files such as httpcore-4.3.3.jar and gson-2.3.1.jar. I have seen many solution to export as runnable jar, Since I don't have any main method how can I export my utility java project to jar file.

My issue is I'm unable to export my project which has no main method as JAR along with my library files in eclipse.

Thanks in Advance

Edit Update:1


回答1:


Used Fat Jar to export My Java project as JAR along with my referenced libraries.




回答2:


Export it as a normal JAR file:

Export -> Java -> JAR File



回答3:


Use export to "Jar File", not "Runnable Jar File"

A "Runnable Jar File" is a jar file with manifest pointing to the the class containing a main method. It allows to run a java application by just calling:

java -jar <your jar file>

instead of

java -cp <your jar file> <your class with main method>

Obviously exporting to runnable jar file does not work if you don't have at least one class with a main method.



来源:https://stackoverflow.com/questions/29928520/export-a-java-project-without-main-method-with-external-jars-to-jar-in-eclipse

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!