开发者

How can I create a self-consistent .jar file with Eclipse?

开发者 https://www.devze.com 2022-12-28 16:20 出处:网络
I wrote my Java application in Eclipse. Now I would like to generate a .jar file which can be run on other systems from the command line. Is there a easy way to do it in Eclipse?

I wrote my Java application in Eclipse. Now I would like to generate a .jar file which can be run on other systems from the command line. Is there a easy way to do it in Eclipse?

In particular I am wondering what should I do with the jar files of external library that I use (should it be included into my .jar file?).

Moreover, should I generate some manifest files?

ADDED:

I see the window in which I can choose "Extract required libraries into generated JAR" or "Package required libraries into generated JAR" and so on. I select the first option, I specify export destination but "Next" button is not activated yet. What else should I specify. I am offered to launch a configuration but i do not want to. Every configu开发者_JAVA技巧ration is associated with a fixed set of parameters given in the command line and I do not want that.


Select you project, then Export => Java => Runnable JAR file

You can then choose to extract/package/copy required libraries into your JAR and also select the class, whose main() method should be executed on startup.

Then you can execute the generated jar via: java -jar yourjar.jar


When you go to Export => Java => Runnable JAR file, You said "Next" button is not activated yet, You don't have to press the next button because you can just press finish, If you don't want the Lauch Configuration, You can manually edit the manifest file later. If you have external libraries you can chose one of the options they give you, extract/package/copy required libraries into jar file

0

精彩评论

暂无评论...
验证码 换一张
取 消