Usually the IDE automates this for you, I use Netbeans and whenever you build the project it generates the jar, which is in the project’s dist folder. In the case of Eclipse I believe he also does it in some way (I don’t know). Now if you want to do it in CMD it is as follows:
1- Create a manifest.txt file in the package directory that contains your entire application with the following content (assuming that its main class is in the app.main package and has the name Mainwindow):
Main-Class: app.main.Mainwindow
Name: app/main/Mainwindow.class
Java-Bean: true
- The first line 'Main-Class: ...' is where you define the package of your main class (class containing the main function), as if it were an 'app.main.Window' import'.
- The second line 'Name: ...' informs which directory of its main class, from the directory of the manifest.txt file, if it is in the same directory as the main package, the first line will be similar to the second, the difference is that you use '/' instead of '.' and have to specify the extension '.class' of the main class.
- The third line 'Java-Bean: true' tells you that you want to use the java bean option.
2-Open the CMD and navigate to the manifest.txt file directory, then type:
jar cfm Applicationname.jar manifest.txt app
So you specify the name of your application, include the manifest file that makes some important specifications about your file (.jar), and define what will be contained in (.jar), in this case the main package that contains everything is the app package.
Is ready your jar!
Here is a full explanation: http://luizricardo.org/2013/11/instalando-configurando-e-usando-o-eclipse-kepler/
– Math
What have you tried?
– Bruno César
Higor, welcome to [en.so]! Eclipse is an IDE (Integrated Development Environment) and one of its objectives is precisely to automate the compilation of projects. I imagine you may be facing a particular problem, so I suggest you be more specific in your question so that we can help you better. Hug!
– utluiz