Wednesday, January 12, 2011

How to add struts capability to a existing core java project

With my earlier projects where we had the struts plug in added to the eclipse. all we used to do is right click on the project and -> Add Struts capabilities. Here it doesn't work since the plug in isn't there. So here is the alternate approach.

1. Go to your Eclipse project folder and you should see a file named ".project" open the file.
2. Search for these lines org.eclipse.jdt.core.javanature
3. Change those lines to become
org.eclipse.jdt.core.javanature
org.eclipse.wst.common.project.facet.core.nature
org.eclipse.wst.common.modulecore.ModuleCoreNature
save the changes you have made.

4. Open one more file called “org.eclipse.wst.common.component” under your ".settings" folder inside your Eclipse project folder. If there is no ".settings" folder inside your project or empty one, you can use from other Eclipse Struts Project, just copy it over.

5. Change the some parameters
Pay attention to (you can ignore other, the application_name usually the Eclipse project name) :
the source-path is relative to the location of your .java files.
the deploy-path is relative to the location of your .class files.
the context-root is the application name, usually the war name or the war-extracted folder name on the server.

4. Close your Eclipse project and open it again.
5. Right click on your project and go to the Properties menu.
6. Choose the Project Facets, select Dynamic Web Module and Java by active the checkbox
respectively(for my case i choose version 2.5 for the Dynamic Web Module and 5 for Java). Click OK.

Hope it useful.

No comments:

REFACTORING

 What is Refactoring? A software is built initially to serve a purpose, or address a need. But there is always a need for enhancement, fixin...