Main Tutorials

Convert Java Project to Web Project in Eclipse

This tutorial shows you how to convert a Java project to Java web application project in Eclipse 4.2, it should work in older version as well.

1. Java Project

A simple Java project.

java project

2. Project Facets

Right click on the project properties. Select “Project Facets“, and click “convert to faceted form…

project facets

Check “Dynamic Web Module” and “Java“, and specify the value.

project facets

By default, Eclipse will generate all “web” related files (like WEB-INF, web.xml) in a “WebContent” folder. If you want change it to another location, Clicks on the “further configuration available…” link.

Modify Faceted Project

3. Web Application Project

Done, the Java project is converted to web application project, see the globe icon on top of the project.

web project

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
37 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Obi
7 years ago

Nice tutorial, mkyong. Good job.
Do you know how to convert a web project back to a Java project? I tried unchecking “Dynamic Web Module” and got the error “Dynamic Web Module 3.0 cannot be uninstalled”.
Thanks

Pavan
5 years ago
Reply to  Obi

I am also having the same problem

Sérgio Berlotto
14 years ago

Tks for this tip !
Work fine for me…

Paulo
1 year ago

I’d like to thank you for your posts. It always helps me.

Sauce dispenser
4 years ago

Bro you are awesome sauce thanks for the tutorial. What would have taken me hours to figure out on my own turned into an easy google search in 5 mins. Thanks

Pavan
5 years ago

If we are using maven project in step 2 in context directory we should add “Target” instead of “src/main/webapp”

Sindhuja
5 years ago

ThanK you so much for this tutorial.. It was very helpful..!!! 🙂

Divya
6 years ago

superrrr!!

shivam
6 years ago

thanks

Trendisoft
7 years ago

Well explained. Great post!

Pawel
9 years ago

Thank you Mkyong!

Raul
9 years ago

Thanks dud. It helped me a lot 🙂

mcm phenomenon
10 years ago

???

Dinesh Kumar
10 years ago

You are awesome dude 🙂

Desiree
10 years ago

Amazing! Its genuinely awesome article, I have got much clear idea about from this article.

dave h
10 years ago

This post has helped me many times… thanks for this document… it is a true lifesaver and blessing.

Basavaraj
11 years ago

Thanks.

Basavaraj
11 years ago

Greta!! thanks

Shivdhwaj Pandey
11 years ago

I want to create a simple web project using eclipse helios but cant able to do so in new project there is no option for web projects?

sap
11 years ago

Hello There. I found your weblog the use of msn. That is a really smartly written article.

I will be sure to bookmark it and return to
read more of your helpful info. Thanks for the post.
I’ll definitely comeback.

harsh
11 years ago

thanks, been a quick help in crucial time !

Forhad
11 years ago

I was thinking to do it manually. But this helps me a lot .Simple and basic tool knowledge but effective .

mohsin azeem
11 years ago

any tutorial about pretty faces ? i need that or any good and clear tutorial sites ??

fermovalcan
11 years ago

it’s very helpful today

it still works ^ ^

Paul Furbacher
12 years ago

Editing the .project file to add natures and builders always had a nasty smell to it. I’d do it, but would hold my nose. What’s the point of an IDE if you have to monkey with files it is supposed to be maintaining.

At least with Indigo (3.7), I have found it much more convenient (and quicker) to simply open the .settings folder in the Package Explorer, and delete all the files in that folder. If you are nervous about taking such a drastic action, make copies of those files in some other folder before deleting.

Then open the project’s properties; click on the Project Facets node. All facets will be available for selection. You’ll have to do additional configuration for some facets, but that’s just par for the course.

One could legitimately criticize this alternative as also having a nasty smell, since I’m monkeying with files which Eclipse should be managing. I wouldn’t disagree. However, for me, it’s a lot less fussy and less error prone than editing natures and builders.

Of course, the “right” way would be to have the eclipse crew formalize such a conversion in their menus, etc., as they do for converting to Maven or JPA projects, for example.

Kawu
13 years ago

Not sure, but this fix should make this procedure obsolete:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=300182

Elridge
13 years ago

This was very helpful! One thing I had to do to get it to work for me was restart Eclipse after Step 4

Engin
13 years ago

Many thanks to Mkyong !
It helped me really !

cirius
14 years ago

Thanks a lot for this tip it was very helpful!

DALI MOHAMED
14 years ago

Merci beaucoup pour cet explicatif

jakob
14 years ago

thanks, that helped me out!

Monty Love
10 years ago
Reply to  mkyong

I tried this in my eclipse 4.2 installation and I don’t see the “Project Facets” item in the
project properties. What’s up with that?

harsh
11 years ago
Reply to  mkyong

Yes it works indeed ! thanks again !