views:

260

answers:

6

Can you publish a .war directly from eclipse to a web server.

I know it's not a programming question, but I still think it's a relevant question.

Thanks

A: 

Yes, you do that

  • Start the build the application
  • Create the war file A WAR (or "web archive") file is simply a packaged webapp directory. It is created using the standard Java jar tool. For example:

cd /home/alex/webapps/mywebapp jar cf ../mywebapp.war * - copy that war file to the following deploy directory in your server say in Jboss its like this "C:\Jboss405\server\default\deploy"

I hope this might be clear, else let me know any issues if you face any issues

harigm
This is manual deployment!!!
Padmarag
Yes its a manual deployment
harigm
+2  A: 

Yes, but it depends a lot on your project configuration. Generally you need to define the server in eclipse, and choose "Run on Server".

See this as an example of deploying on JBoss server from eclipse.

In case you are using Ant then using "deploy" target will work.

Padmarag
You're misstaken at least about the maven part. The deploy stage in the maven lifecycle is about deploying an artifact to a maven repository and has little to do with deploying to a web server
Buhb
@Buhb Thanks for pointing. We have the deploy target to deploy to local server. I mixed these two things :) Updating the answer.
Padmarag
+1  A: 

If your project is setup as a web project in Eclipse, you can choose to run it on a server (You'll have to configure the server first). This will publish the war file directly on the server from Eclipse.

Rahul
+2  A: 

yes you can.

right click on the project, select export -> select web - > then war and give destination which is your deploy folder.

GK
+1  A: 

This is easiest if the web server has an auto-deploy facility, with a magic directory. Then just File-> Export the WAR file into the auto-deploy folder.

If not, or if you want to be able to debug the WAR file inside Eclipse you need to have an appropriate server connector in the WTP module (which is included by default in the JEE edition of Eclipse).

If you want to programmatically push the WAR file to a given server directly from within Eclipse, then you can e.g. use the Tomcat Ant tasks - http://tomcat.apache.org/tomcat-5.5-doc/manager-howto.html#Executing%20Manager%20Commands%20With%20Ant - or use the Cargo library to do this with many different types of servers - http://cargo.codehaus.org/

Thorbjørn Ravn Andersen
A: 

I created my own ant file, and set eclipse to use that ant file when building. Part of that ant build file is a target that publishes to Tomcat, so I can just right click and chose install from within eclipse.

Eclipse pic

The basis of such an ant file is here: http://tomcat.apache.org/tomcat-6.0-doc/appdev/build.xml.txt

nos