Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Converting a Java Project to a Dynamic Web Project in Eclipse

DZone's Guide to

Converting a Java Project to a Dynamic Web Project in Eclipse

· Java Zone
Free Resource

What every Java engineer should know about microservices: Reactive Microservices Architecture.  Brought to you in partnership with Lightbend.

To convert a Java Project to a Web Project switch to or open the Resource Perspective of the project, in the root of the project. Open the .project file and make sure the builders and natures are present that are needed for a web project. See the example below, the name should be the name of your project, the most important nodes are the nature children in the natures node:

<projectdescription><name>testProject</name><comment></comment><projects></projects><buildspec><buildcommand><name>org.eclipse.jdt.core.javabuilder</name><arguments></arguments></buildcommand><buildcommand><name>org.eclipse.wst.common.project.facet.core.builder</name><arguments></arguments></buildcommand><buildcommand><name>org.eclipse.wst.validation.validationbuilder</name><arguments></arguments></buildcommand></buildspec><natures><nature>org.eclipse.wst.common.project.facet.core.nature</nature><nature>org.eclipse.jdt.core.javanature</nature><nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature><nature>org.eclipse.jem.workbench.JavaEMFNature</nature></natures></projectdescription>

Once you’ve updated the .project file you can close the file and right click and choose properties on the project. When the properties window opens click on Project Facets. The Facets grid is probably empty, click the Modify Project button. Check the Dynamic Web Module and Java Facets, choose the Java and Servlet version that applies to your project. Click Next and specify the existing or new location of your src and web content directories. Click Finish.

As a final step I would recommend modifying the build path to compile your source directly into your /WEB-INF/classes directory by selecting Java Build Path and modifying the Default output directory.

Now you should be able to create a local tomcat server, or if you’ve already created one you should be able to add the project to the server by right clicking the server and choosing Add and Remove Projects.

Original article at http://greatwebguy.com/programming/eclipse/converting-a-java-project-to-a-dynamic-web-project-in-eclipse/.

 

Microservices for Java, explained. Revitalize your legacy systems (and your career) with Reactive Microservices Architecture, a free O'Reilly book. Brought to you in partnership with Lightbend.

Topics:
eclipse ,project ,switch project type

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}