Eclipse Tips'n'Tricks

This page collects some tips and ideas on how to fix regular issues with Eclipse, which is an awesome development UI. Please add your signature to the tips you add so that people can contact you in case of questions.

Bugzilla integration

Since eclipse-europa is out, you can easily integrate the 52n Bugzilla into eclipse:

  1. select your project
  2. right-click on preferences
  3. select Task Repositories
  4. click Add
  5. enter
  6. enter your TWiki credentials
  7. now, you can add the desired bugs (you may need to activate the Task List view!

Declaring a Java project as eclipse WTP Dynamic Web Project

The eclipse webtoolsplatform enables a developer to use tomcat to run a web project within eclipse while developing. it is similar to the sysdeo plugin but easier to handle. For example you can debug the project like a normal Java project.

If you checkout a project which is actually a Dynamic Web Project, but eclipse does not recognize it, you are able to set it as a Dynamic Web Project afterwards with two simple settings.

  1. Import/Checkout the Project of interest
  2. Go to the pojects properties
  3. Set up first the Project Facets, create a new facet and enable the Java facet and the Dynamic Web module
  4. Click finish
  1. Go to Targeted Runtimes
  2. If you already set up the targeted runtime, choose it click Apply and Ok. Now your project is an eclipse web project.
  3. If there is a targeted runtime, you can create a new one by clicking on New.... Choose the runtime (For tomcat expand the Apache folder and choose your version you have installed on your maschine)
  4. Click Next, browse to the home directory of your previously selected tomcat and click Finish.
  5. Now your can click OK in the properties window of the project.
  1. The project is a Dynamic Web Project now, so go to Window -> Open Perspective -> Other -> Java EE (default)
  2. By clicking the right mouse button on the project you can run the project as Run on server. Follow the wizard and click Finish. The same way you can debug the project by clicking Debug as in the projects context menu.

Run a J2EE project together with a seperate project

Problem: You have got a framework which can be extended by plugins. If the J2EE project is running as webapp in a tomcat, you could copy the plugin as jar file into the WEB-INF/lib directory of the webapp and it works. If you want to develop such a plugin it makes sense to seperate plugin and framework into their own project. But when running the webapp it does not know about the plugin project and its runtime libraries.

The WEB-INF directory of the J2EE project is ecapsulated from the outside. So do the following steps to let the J2EE project know about an externam project.

Go to the Order and Export tab of the external project of Java Build Path and mark the runtime libraries as exported. Now import these libraries and the external project itself as J2EE Module Dependency into the framework properties.

Now, you can run the framework as webapplication within eclipse. It knows and can use the external project (and it exported/imported runtime libs) from now on as it where copied as jar into the WEB-INF/lib folder.

-- HenningBredel - 12 Oct 2008

Remote Debugging of a Tomcat Web Application from Eclipse

Tested with Windows XP and Eclipse Ganymede.

1. Start Apache Tomcat X.X‚ right-click on icon in Task Bar and select "Configure...".

2. Go to the tab "Java" and add the follwing lines to "Java Options:"

-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=[your port, e.g. 1111]

The adress can be chosen freely. Rember it for later, you need it again in Eclipse.

3. In Eclipse: Go to "Run" > "Debug Configurations" and choose "Remote Java Applications" in the left hand menu. Create a new configuration and give it a name, e.g. " remote debug" (see picture):


  • Project: [your name for the project]
  • Connection Type: Standart (Socket Attach)
  • Connection Properties:
    • Host: [your host]
    • Port: [your port, e.g. 1111]
Click "Apply" and then "Close".

4. Now start you web-app as you normally do in the Tomcat at [your host].

5. Set Breakpoints in the code within Eclipse.

6. Start the just created debug configuration: "Run" > "Debug Configurations" > select the newly created Remote Java Application > click the "Debug" button. Eclipse connects to the Java Virtual Machine or gives an error message if it cannot. It switches to the debug view if a breakpoint is reached.

Converting project to Java project

Sometimes you check out a project from a (SVN) server and only a "normal" project is created, not a Java-Project. That way, you miss out on some important features! There are two ways of fixing this:

  • Delete the project without deleting the files, then create a new project with the same name. Eclipse asks you, if you want to import the content of the existing folder, which you can accept.
  • Edit the .project file and the .classpath file:
    • Open the .project file and add java nature and builders:
    • In .classpath, reference the Java libs:
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>

Based on:

Running a WTP configured web application on Tomcat together with a non-WTP application

I had a project in Eclipse with a web application and ran it on a Tomcat web server that was configured using the Web Tools Project (WTP) Eclipse plugin. Now I wanted to run an additional web application in the same Tomcat that was deployed using an ant script rather than WTP. But I could either start the Tomcat via skript and run the manually deployed webapp or start the Tomcat in Eclipse and run the WTP webapp.

The solution:
  • Set the "Server Locations" radio selection to "Use Tomcat installation" in the WTP configuration of the Tomcat (Window -> Show View -> Servers, then right-click on the desired server and select "Open").
  • If that is not possible, you have to delete the temporary folder in [your workspace]/.metadata/.plugins/org.eclipse.wst.server.core/, probably named "tmp0" or similar.
  • Refresh your "Servers"-project and the WTP-webapp project.
  • Optionally fix the build-path in the folder with the WTP webapp also (re-add the "Web App Libraries").
  • Start the Tomcat in Eclipse, both projects (as well as webapps like the tomcat manager)

Adding JUnit and Hamcrest Static Imports to Content Assist

Open Window » Preferences » Java » Editor » Content Assist » Favorites

Add the following entries (when adding, use "New Type" and ommit the .*) - yes, you have to add them one by one.


-- DanielNuest - 01 Oct 2009
I Attachment Action Size Date Who Comment
WTP_facet_settings.jpgjpg WTP_facet_settings.jpg manage 129 K 15 Feb 2008 - 16:27 HenningBredel  
WTP_targeted-runtime_settings.jpgjpg WTP_targeted-runtime_settings.jpg manage 187 K 15 Feb 2008 - 16:27 HenningBredel  
bugzilla.pngpng bugzilla.png manage 159 K 10 Jan 2008 - 10:55 UnknownUser  
remotedebugging-1.pngpng remotedebugging-1.png manage 8 K 29 Jan 2009 - 17:13 UnknownUser Tomcat settings for remote debugging
remotedebugging-2.pngpng remotedebugging-2.png manage 40 K 29 Jan 2009 - 17:18 UnknownUser Eclipse settings for remote debugging
Topic revision: r10 - 15 Oct 2014, EikeJuerrens
Legal Notice | Privacy Statement

This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Wiki? Send feedback