Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does Eclipse place the .war file?

I'm new to Java EE web development. I've created a JAX-RS based web application in Eclipse which I'm running on Tomcat. The project has dependencies managed by Maven. Everything is working fine. However now if I have to ship this project, I'd assume I would have to provide a .war file to the user.

So here's my questions:

  1. Where does eclipse place this war file?
  2. Will this file have everything in it, in the right order to run as web application or do I need to provide any other file in addition, like web.xml or pom.xml?
  3. If the user of the application has downloaded tomcat, does all he/she needs to do it copy the .war file into the Tomcat directory and right-click to run?
like image 599
Zeus Avatar asked Apr 12 '16 18:04

Zeus


3 Answers

  1. Eclipse deploys WAR to the tomcat. Exact place depends on your tomcat settings. See details here: Where does Tomcat in Eclipse store the expanded WAR? You mentioned a pom.xml file so you probably use some maven plugin (like this https://maven.apache.org/plugins/maven-war-plugin/) to build the war file. Refer the plugin documentation to understand how to configure the war artifact creation.

  2. Everything is inside (in your case the project is properly configured in maven). You should just deploy to the server.

  3. You should not right click or whatever. Just place into the webapps folder in the tomcat installation or deploy via manager app. I gues you should read the documentation here https://tomcat.apache.org/tomcat-6.0-doc/deployer-howto.html to understand what is deployment and how to do it.

One more useful link:http://www.codejava.net/ides/eclipse/eclipse-create-deployable-war-file-for-java-web-application

like image 193
Akceptor Avatar answered Oct 18 '22 01:10

Akceptor


right click in project > export > web project > .war Then copy the .war file into webapp directory of your apache tomcat.

like image 27
miaguicam Avatar answered Oct 18 '22 03:10

miaguicam


If you use maven and you configured it properly the easiest way to create your war is to call:

$ mvn clean install

in your project directory, in the location of pom.xml. After that you will find generated war in: path_to_your_project/targe/your_application.war

like image 1
Grzegorz Domagała Avatar answered Oct 18 '22 02:10

Grzegorz Domagała