- Details
- Written by Nam Ha Minh
- Last Updated on 05 August 2019   |   Print Email
This article shows you how to change server location and deploy path for Apache Tomcat server in Eclipse IDE. You know, by default Eclipse publishes Java web applications in the workspace metadata directory so you see the option
Use workspace metadata (does not modify Tomcat installation) in the Tomcat settings view in Eclipse:
For example, if your workspace directory is
E:\Java\JavaEE, then you see that Eclipse deploys the application in the server location which is a directory looks something like this:
e:\Java\JavaEE\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps
What if you want to deploy your Java web applications in another directory: Tomcat installation directory or your own directory? But you see all the options for Server Locations are grayed out, right? So how to make change?Here you will see how.Read the instruction carefully:
Server must be published with no modules present to make changes.
This sounds logical because you can’t change server location and deploy path if there are still applications deployed on the default path. That means if you want to change server location you have to delete all the currently deployed applications on the server. To remove a deployed application from the server, simple select it in the server view and press
Delete key. The server must be empty like this:
And when there’s no more application, you see all the options for
Server Locations are enabled:
Now, you can change the server location and deploy path as you wish. For example, to make Eclipse deploy your Java web applications in
webapps directory of Tomcat, make the following changes:
Then click
Save (Ctrl + S) to make the changes take effect. Now drag and drop the project from the
Project Explorer view to
Servers view to deploy it to a new location.Similarly, you can specify your own location for server location and deploy path, for example:
With this change, the server configuration is copied to the
F:\WebApps directory and the applications are deployed in the
F:\WebApps\Deployed directory. And note that in this case, the server path must not be the workspace directory.
Other Tomcat Tutorials:
About the Author:
Nam Ha Minh is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on
Facebook and watch
his Java videos you YouTube.