JMeter + Eclipse HOWTO
Mar 10 2004
Special thanks to (text taken from)
Revision history
- Mar 09 2004 - Update (Eclipse 3.0, Ant scripts)
- Nov 12 2003 - Update (Eclipse 2.1 + JMeter 1.9.1+)
- Dec 12 2002 - The first release
Abstract
This document describes briefly how to develop the JMeter project with Eclipse IDE. Eclipse is a very powerful development environment with following features:
- It's fast! Although it's written in JAVA like many other development platforms, it doesn't use SWING, which is big and slow; it uses an especially created SWT widget toolkit instead. This tookit doesn't emulate widgets in java, but it uses native system widgets (GTK on linux), which improves performance substantially.
- Very functional editor/package browser with syntax highlighting and syntax hints.
- Compiles java classes on the fly (when waiting for user input or saving a file), so one doesn't have to wait when launching an application. Furthermore, one sees errors immediately.
- Very nice debugger.
- Powerful code refactoring: when you want to change the name of a method or change parameters, don't hesitate to do it. Eclipse intelligently changes appropriate things regarding to java syntax (you won't get this result using simple search/replace).
- JavaDoc integration.
- CVS integration.
- Can automatically create getter and setter methods.
- CPL licence (OSI approved).
- Last but not least: search with regard to java syntax. You can just mark an identificator and click "open super implementation" or "find any reference to.." or "find declaration of...". It helps very much when exploring the internals of an unknown application.
- Many (many) more...
Eclipse is available for download for different platforms at http://www.eclipse.org
Multiple Workspaces
Most Eclipse formatting settings are managed at the workspace level. If you work on other projects in addition to JMeter, you probably don't want the JMeter formatting to apply to your other projects. One way to manage this is to set up multiple Eclipse workspaces -- one for JMeter, and one (or more) for other projects. To use multiple workspaces, simply start eclipse with the "-data" parameter:
eclipse -data c:\workspace_JMeter
You could also create a batch file, shell script, or Windows shortcut to automatically specify the workspace so you don't have to type it each time.
Setting up JMeter + Eclipse
I assume you downloaded Eclipse IDE and have it working.
Accessing CVS
- Open the CVS perspective with
and
buttons
- Invoke the popup menu and select "New"|"repository location"
- Fill appropriate entries as pictured below, entering anoncvs as a password.:
- You should see the apache cvs tree as pictured below. Unfold HEAD, select jakarta-JMeter and then select "Check Out as ..." from the pop-up menu

- Select "JAVA project", and give a name for the project in next dialogs. I will assume I it is is named jmeter-pserver for the rest of this document.
- Wait for the cvs checkout to complete
Setting up paths
After the checkout you'll see something like this:

It means you have the source paths improperly installed. To set them up, do the following:
- Close this project
- Copy the jmeter-pserver/eclipse.classpath file to jmeter-pserver/.classpath (you will have to overwrite the jmeter-pserver/.classpath file eclipse created for you
- Open the project again
- Now the source folders and jar libraries are mounted properly
NOTE: There are some optional libraries JMeter depends on. This setup defines exclusion filters for all the classes that need optional libraries (you would get compiler errors from Eclipse otherwise). Remove these exclusion filters if you have optional libraries installed. For further details refer to jmeter-pserver/eclipse.readme)
Running JMeter with Eclipse and Ant
- Select Window|Show View|Ant. On the view like depicted below click the "Add Buildfile" button

- Select the build.xml file

- Run the ant target package (running "all" target would result with a clean compile, which would erase classes compiled by Eclipse itself).
NOTE: The "package" target checks if there is something to compile before packaging. When working with Eclipse and having the "Window|Preferences|Workbench|Perform build automatically on resource modification" option turned on, the IDE compiles almost everything when saving the source, so checking if there is something left to compile is not neccessary. You can consider using the package-only target, that does not compile anything. This will shorten the compilation time
- After compiling JMeter you can make it run in a usual way (starting the jmeter-pserver/bin/jmeter script). But - behold! - there is a possibility to run and debug it under Eclipse.
Running and debugging from Eclipse
- Find the NewDriver class on "Java browser perspective"

- Select "Run"|"Run ..." from the menu
- Select "Java application" from the side tree and click "New". JMeter running configuration will be added
- Select the "Arguments" tab, uncheck "Use default working directory" and correct the working directory field to
jmeter-pserver/bin
- Select the "Classpath" tab, uncheck the "Default class path" checkbox, remove the "jmeter-pserver" entry (it should be the first one), click "Add JARs" and add bin/ApacheJMeter.jar. The final setup should look like this:
- Configure the source for debug: choose the "Source" tab, uncheck the "Default source lookup path" checkbox, click "Add Projects...", check the jmeter project. Thie final setup should look like this:
- Click "Run"
- From this time on you can run and debug JMeter simply by pressing
and
buttons
Running and debugging JMeter without Ant
It is very simple to use Ant while using Eclipse; you can even run and debug a code built in such a way. However, this method has one drawback. It can be tiresome always to run this package-only target; it also takes some time. You can configure your environment to run JMeter directly, without all that repackaging. Do the following:
- In the "Project properties" window exclude *.resources and images from src/core exclusion filter. The exclusion filter should look like this:
- Make sure the directory jmeter-pserver/lib/ext is empty. If not - run ant clean and then rebuild the project with Eclipse
- Add the following one line to your jmeter-pserver/bin/jmeter.properties file:
search_paths=build/protocol/ftp;build/protocol/http;build/protocol/java;build/protocol/jdbc;build/protocol/ldap;build/protocol/tcp;build/components;build/core;build/default;build/functions;build/htmlparser;build/jorphan
- Find the NewDriver class on "Java browser perspective"

- Select "Run"|"Run ..." from the menu
- Select "Java application" from the side tree and click "New". JMeter running configuration will be added
- Important: Select the "Arguments" tab, uncheck "Use default working directory" and correct the working directory field to
jmeter-pserver/bin
- Select the "Classpath" tab, make sure the "Use default class path" option is checked
- Select the "Source" tab, make sure the "Use default source lookup path" option is checked
- Click "Run"
- From this time on you can run and debug JMeter simply by pressing
and
buttons
Formatting files
In order to match the conventions agreed to by JMeter committers in January 2003 (see [the mailing list archive]) the following settings are recommended. These settings are present in Eclipse 2.1.1 -- earlier or later versions probably have similar settings, but possibly in different places.
- Select Window | Preferences. Choose Java | Code Formatter. Use the following options in the "New Lines" tab. (Options which aren't listed are up to you to decide.)
- Insert a new line before an opening brace (selected)
- Insert new lines in control statements (selected)
- Insert new line between 'else if' (deselected)
- Insert a new line inside an empty block (selected)
- In the "Line Splitting" tab, "Maximum line length" should be set to 80.
- In the "Style" tab, use the following options:
- Insert space after a cast (selected)
- Insert tabs for indentation, not spaces (deselected)
- Number of spaces representing an indentation level: 4
- In Java | Editor, use the following settings:
- Print margin column: 80
- Show print margin (selected) (This way you can see where 80 columns is at when writing code and comments.)
NOTE: ASF officials strongly discourage using of an @author tag, because of licencing issues (ASF Board Summary for February 18, 2004).
Comments
Please send your comments concerning eclipse+JMeter as well as grammar/spelling issues either to JMeter mailing list or to me (m.kostrzewa@pentacomp.com.pl).