I am trying to create an EAR file from the command prompt. I have used
jar -cvf myServletWAR.ear .
But my question is, how can I get this EAR
If you want to create an ear from the command line, following are the options that you can try.
Option 1. Using an ant build and use the ear task. Configure this ear task as stated in stackoverflow question on ant ear task usage
Note: Maven based build is preferred over ant these days.
Option 2. If you can use maven, configure your modules and use maven ear plugin to generate an ear. The below command will be able to generate the ear.
mvn clean package
Refer to the maven question regarding a Java EE project for more information on configuring war, jars for an ear.