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.
Since eclipse-europa is out, you can easily integrate the 52n Bugzilla into eclipse:
- select your project
- right-click on
- enter your TWiki credentials
- 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.
- Import/Checkout the Project of interest
- Go to the
- Set up first the
Project Facets, create a
new facet and enable the
Java facet and the
Dynamic Web module
- Go to
- If you already set up the targeted runtime, choose it click
Ok. Now your project is an eclipse web project.
- 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)
Next, browse to the home directory of your previously selected tomcat and click
- Now your can click
OK in the properties window of the project.
- The project is a
Dynamic Web Project now, so go to
Open Perspective ->
Java EE (default)
- 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.
- 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):
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.
- Project: [your name for the project]
- Connection Type: Standart (Socket Attach)
- Connection Properties:
- Host: [your host]
- Port: [your port, e.g. 1111]
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: http://stackoverflow.com/questions/179439/how-to-change-an-eclipse-default-project-to-a-java-project
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.
- 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