In this tutorial, I will show you steps to rename a Java web project, It’s for the J2ee projects those are built using JSP, and Servlet.
Below are the required stages, that we need to follow to change the existing project name.
- Folder level changes
- Package level changes
- Class level changes
- Required changes into pom.xml
- Required changes to the properties configuration
- Changes in the Application context
Note: Here in this article, we are using an example of a project which has the existing name of “Mobile Shop” and needs to change to “Computer Shop”.
Folder level changes
Rename the project root folder name “Mobile Shop” to “Computer Shop”, and import the project with a new name.
After import, if it’s showing the old name in IDE then update it in IDE as well by following the below steps
Right-click on the project ==> Refector ==> Rename
Package level changes
To update the packages and sub-package names again Right-click on the package==> Refector ==> Rename ==> Select check as required ==> click OK.
Class level changes
Check the class name if required change the class name and imported the package names as well.
Required changes into pom.xml
Update the new project name from pom.xml at the following location
- <groupId>
- <artifactId>
- <name>
- <finalName>
Changes in the Application context
Update the new name as AppContext variable. It depends on the project in which layer developers manage the appContext. As per the standards, it should be into controllers.
Other Quick steps
- Update the database name and other connection properties.
- Force update maven.
- Build the project with the required JDK version.
You might face errors on the Jsp page Because Jsp will not auto-update the package names, which we have to do manullay if you getting errors at the top of the Jsp pages just update the new package name there.