Complete end to end configuration of JMeter in Eclipse
Here we will learn how to Configure JMeter in Eclipse. If you are planning to do some customization in JMeter, then, you must be thinking of using some IDE like Eclipse because a lot can be done using an IDE.
There are a lot of blogs and tutorials on this topic, but share partial information regarding End to End configuration.
This is a long post with series of configuration, but resolves all the problem you may face with Eclipse and JMeter Integration, for ease of reading it is divided into three parts:
- Import JMeter Source into Eclipse
- Run JMeter using ANT target
- Settings to Properly Configure JMeter in Eclipse
1. Import JMeter Source into Eclipse
For that, you will have to first configure JMeter source in some IDE like eclipse.
- First, create a Java project
- Import JMeter source into the recently created Java project
Now, we have successfully imported the JMeter source in Eclipse. Now, let’s launch the JMeter.
2. Run JMeter using ANT target
There are two ways to launch JMeter:
Standard method – Using Command line, the most common way to launch JMeter
- Using ANT Target – JMeter contains ANT target to launch JMeter
We have an ANT target in JMeter that makes this task really easy. So, we will use the second method (Using ANT Target) to launch JMeter
NOTE: You just need the ANT plugin installed in eclipse to take advantage of ANT. You need to have Ant (Version 1.9.6) in your IDE
To use targets define build.xml, let’s first add the build.xml files to Ant window in Eclipse.
There are two build.xml files, one is in “root” folder and another is in “extras” folder. Add both these build.xml files.
Now, use the ANT Target (run) defined in build.xml file kept in “extras” folder
As soon as you execute the “run” target you will see errors in the src folder and JMeter will not launch.
Now, to resolve these issues we have to do some more configuration. Let’s move to the 3rd part of the post
3. Setting to Properly Configure JMeter in Eclipse
You will face few challenges in the smooth running of JMeter project in Eclipse. We will now see the solutions to these challenges.
Eclipse creates some files and folders when you create a Java Project in Eclipse that includes a bin folder. JMeter already has a bin folder that contains important property files and executable to run the JMeter jar file. Eclipse will use same JMeter “bin” folder as output folder (to keep .class files when we build the Java project) because of which Eclipse deletes all the content that is already present in the folder.
Because of this clash, eclipse deletes all the files from this “bin” folder when we build the JMeter project using eclipse.
Solution: Change the eclipse output folder
Now, copy the missing files from the unzipped JMeter source project to the “bin” folder of eclipse JMeter project, manually.
Challenge 2: Errors in the Project
You will see errors in the project because of missing JMeter jar files.
To resolve these errors we have to do following 3 steps
1. Download the required “jar” files
2. Configure the Build Path
3. Add Source folders to the build path
Download the required “jar” files
JMeter source does not contain the jar files as a bundle. But that doesn’t mean you have to download it manually or copy paste from the JMeter binary distribution. You can download it in just one click using ANT target.
JMeter uses ANT as a build tool that has different ANT targets for different actions necessary for project building. For example, downloading of all the required jar files.
Now, download the required jar files. There is a download_jar target in build.xml kept in the root folder that downloads all the missing jar files.
Configure Build Path
Now, after downloading the jars, you can use source JMeter like you use binary JMeter, but we still see errors in Eclipse even though the jar files are present in the “ext” and “lib” folders now. But these errors are because eclipse doesn’t know from where these jar files need to be picked. That is why eclipse displays these errors.
Now, to fix this we simply have to add all the jar files present in “lib” and “ext” folder into classpath using “Configure Build Path”
Once done, we will start seeing intelligence help one’s eclipse know from where these jar files are to be picked.
You may still see few files showing “cross/error” symbol. If you check the error by opening one of those java files you will observe.
Add Source folders to the build path
You will still observe these errors in the Java file related to the wrong package. To resolve this we have to add folders to the build path.
Add all these folders to the Java Build Path to resolve the errors.
I hope this article was helpful to resolve all the issues you faced with Eclipse and JMeter integration.
Congrats!!… If you have reached the end of this article and JMeter to work smoothly with an IDE without any errors.
If you still facing any issue just write a comment below. I will try my best to help you out.