Command to create war file in command prompt in java

Creating war from jar in command prompt:

In order to create the war file, you need to have the jar file first. Then go to project location say,

C -> Apache software foundation -> Apache Tomcat -> Webapps -> Guru

(consider guru is the project now and we need to create the war file for the same).

Go the above location in the command prompt and type the  jar -cvf guru.war  *“.
Please ensure that you have created the jar file in the above location. Don not forget to type the asterisk followed by guru.war.

Creating jar file:

you can create the jar file in any of the below ways,

1. Using eclipse

Just right click on the project and type export -> jar and save.

2. Using the command:

jar cf jarfilename.jar inputclass.class

jar cf guru.jar guru.class

here guru.jar is the jar file that you are going to create and guru.class is the input class.

Note:

1. If you have more than one class then you can give like this, (separate the classes using the space)

jar cf guru.jar guru.class add.class sub.class

2. cf or fc both gives same output. But both should be mentioned, order not an issue.

 

Thanks for reading this post………!!!

936 total views, 2 views today

Leave a Reply

Your email address will not be published. Required fields are marked *