Developer How-To Use Eclipse Guide
[edit]
How to incorporate Subversion within Eclipse
There is an Eclipse plugin for subversion called subclipse.
For Eclipse 3.2 and 3.3, the URL with subversion 1.2.x, the URL is http://subclipse.tigris.org/update_1.2.x
[edit]
How to Debug a Web Application with Eclipse
Add the following to the java command used to launch Tomcat (e.g., in the service settings if running as a Windows service):
- -Xdebug
- -Xnoagent
- -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5000
Under configurations you’ll find an entry "Remote Java Application." Create a new Remote Java Application, choose a project, leave the connection type to "standard (socket attach)," and for connection properties choose "localhost" and "5000" (change these if you’re using a different port or a different machine to run tomcat).
Start up tomcat and then debug with this new Remote Java Application and breakpoints within the code will open within Eclipse.
- Notes:
- Tomcat 6 users start debugging by running catalina.sh jpda start to debug on port 8000
[edit]
How to 'Watch' Variables (while debugging)
While debugging a program, select (highlight) a variable or expression and then select Watch from the Run menu or context menu.
[edit]
Toggling breakpoints in your code
Use the Window → Show View → Other... menu item to open a dialog of possible views. Find Debug → Breakpoints and select it. The breakpoints view will list all defined breakpoints and let you optionally enable/disable/remove them.
[edit]
Tune the MyEclipse environment (commercial, optional)
- Speed up JSP files by turning off validation and changing the default editor
- Under Window -> Preferences, make the following changes:
- Make the 'Classic' JSP editor the default — Go to
General -> Editors -> File Assocations -> .jsp code> and set MyEclipse 'Classic' JSP Editor as default - Turn off JSP validation — Go to
MyEclipse -> Validation code> and uncheck JSP Validator
- Make the 'Classic' JSP editor the default — Go to
- Under Window -> Preferences, make the following changes:
[edit]
How to Create a Project with Existing Source
[edit]
Use Case
- You have an existing Eclipse workspace folder.
- You no longer have projects in Eclipse for the source code in the workspace folder.
[edit]
Solution
[edit]
How to Install OpenMRS Code Style
- We use the automatic formatting feature of Eclipse to generate consistently formatted code
- Simply use
control-shift-f code> to format a file - OpenMRS formatting file for Eclipse: OpenMRSFormatter.xml
- Install at Window -> Preferences -> Java -> Code Style -> Formatter
- OpenMRS code template file for Eclipse: OpenMRSCodeTemplate.xml
- Install at Window -> Preferences -> Java -> Code Style -> Code Templates
- Simply use
- Use
control-shift-o code> for finding/formatting/organizing imports - Very useful!

