Automation Testing

How to Call a Jar File or Java Class from QTP

By Test Guild
  • Share:
Join the Guild for FREE

Recently, my team had to use QTP to capture an HL7 message from a web application and parse the info. We could have written our own parser, but it was easier to use something like HAPI

QTP to capture the HL7

We decided to use QTP to capture the HL7 message from a textbox and write its contents to a file. We then called the jar file that uses HAPI to parse the HL7. The parser then writes the results to another file. QTP reads the parsed file to validate certain fields in our application.

QTP How To Call the Jar File

To call the jar file, you can use QTP’s SystemUtil.Run like this:

SystemUtil.Run “cmd”,”/c java -jar parsingclass.jar”,””

To call the java class

For a java class you would do something like this:

SystemUtil.Run “cmd”,”/K java D:\HL7Parser\bin\CORUExtractorFlow1151.class”,””

Explanation About the Call Jar File Code

 SystemUtil Object is a QTP object that can be used to control an application or process during a test run.

The Run method runs a file or application. cmd starts a new instance of a command interpreter.

/K is a parameter that runs the command and leaves the command window open. (If you want to close the command window instead of keeping it open, you would need to replace the /K parameters with the /C parameter.) For more info on CMD and its parameters, check out Microsoft’s documentation website

For move complicate UFT Java calls

If you have a more complicated Java DLL that you need to interact with, you could use Service Test 11, which contains a call java class activity. With a “Unified Functional license ,” you could call Service Test from QTP; in our case, however, this would have been overkill, so we kept it simple by using the method described above.

A bearded man with blue glasses and a black-and-white jacket smiles at a microphone in a studio setting.

About Joe Colantonio

Joe Colantonio is the founder of TestGuild, an industry-leading platform for automation testing and software testing tools. With over 25 years of hands-on experience, he has worked with top enterprise companies, helped develop early test automation tools and frameworks, and runs the largest online automation testing conference, Automation Guild.

Joe is also the author of Automation Awesomeness: 260 Actionable Affirmations To Improve Your QA & Automation Testing Skills and the host of the TestGuild podcast, which he has released weekly since 2014, making it the longest-running podcast dedicated to automation testing. Over the years, he has interviewed top thought leaders in DevOps, AI-driven test automation, and software quality, shaping the conversation in the industry.

With a reach of over 400,000 across his YouTube channel, LinkedIn, email list, and other social channels, Joe’s insights impact thousands of testers and engineers worldwide.

He has worked with some of the top companies in software testing and automation, including Tricentis, Keysight, Applitools, and BrowserStack, as sponsors and partners, helping them connect with the right audience in the automation testing space.

Follow him on LinkedIn or check out more at TestGuild.com.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

30 AI Terms Every Tester Should Know

Posted on 04/24/2025

Why This AI/ML List Matters to You (and Your Testing Career) AI and ...

5 Top Model Context Protocol Automation Tools (MCP Guide 2025)

Posted on 04/09/2025

What is Model Context Protocol (MCP) Model Context Protocol (MCP) is an open ...

What is TDD (Test Driven Development)

Posted on 04/05/2025

What is Test-Driven Development (TDD)? Test-Driven Development is a software development approach that ...