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 configuration is associated with a fixed set of parameters given in the command line and I do not want that.
Open the Jar File wizard In the Package Explorer select the items that you want to export. If you want to export all the classes and resources in the project just select the project. Click on the File menu and select Export. In the filter text box of the first page of the export wizard type in JAR.
FYI: In simple terms, the difference between a JAR file and a Runnable JAR is that while a JAR file is a Java application which requires a command line to run, a runnable JAR file can be directly executed by double clicking it.
You depend on the Jar file which contains class bytecode (compiled) of java code. You can't edit any of such files directly in the project you are using it. Thought you can always extends functionalities in your current project using simple inheritance concepts.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With