[英]How to make jar file from eclipse project including library?
I want to make my project into a jar executable. 我想将我的项目制作为jar可执行文件。
That much I can do but I need my external library as well. 我可以做很多事情,但是我也需要我的外部库。
How do you specify the location of an external library? 您如何指定外部库的位置? Right now I have added it to my eclipse project,but later on I need it to execute my program outside of eclipse on a server.
现在,我已将其添加到eclipse项目中,但是稍后,我需要它在服务器上的eclipse之外执行我的程序。
The Library is the postgres-jdbc driver to connect to database. 库是连接数据库的postgres-jdbc驱动程序。
Do you mean Fat Jar
or Runnable Jar
ie a single jar which will contain all it's dependent jars in it. 您是说
Fat Jar
还是Runnable Jar
即单个Jar,其中将包含所有从属的jar。
If yes, it can be generated in eclipse using File -> Export -> Java -> Runnable Jar 如果是的话,可以使用File-> Export-> Java-> Runnable Jar在eclipse中生成
Optionally you can specify the start-class
having the main method. (可选)您可以指定具有main方法的
start-class
。
If you don't want as a Runnable jar
, you've to add all your dependent jars in classpath before starting your application. 如果您不想作为
Runnable jar
,则必须在启动应用程序之前将所有依赖的jar添加到classpath中。
java -cp <add all lib> -jar <jar-file-name>.jar
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.