Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Three ways for Beanshell of jmeter Learning Guide to call java code

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

You can customize classes and methods in jmeter beanshell, and you can also call external existing java files, class files, and jar packages.

Here we will talk about calling external java files, class files, and jar packages respectively.

First, call java file

Syntax:

Source ("java file path")

The file path can be either absolute or relative.

Example:

Source ("E:\ eclipse\ workspace\ MD5\ src\ jmeter\ MD5.java")

Or:

Source ("MD5.java");-- the file is located in the jmeter bin directory

String strMd5 = MD5.GetMD5Code ("123456")

Second, call class file

Syntax:

AddClassPath ("directory where the class file is located")

Import class name

Example:

AddClassPath ("C:");-"can be a parent directory or an ancestor directory"

Import com.MD5

String strMd5 = MD5.GetMD5Code ("123456")

The path path of the imported class file is different from that of the imported java file. The comparison is as follows:

Source ("E:\ eclipse\ workspace\ MD5\ src\ jmeter\ MD5.java");-- you must specify the full path to the file when using an absolute path.

AddClassPath ("C:");-- the class file is fine as long as it is on disk C, not necessarily in the root directory of disk C. you don't have to specify the full path.

3. Call jar package

Usage:

Import the jar package in the test plan, or put the jar package in the jmeter lib directory ahead of time and restart it

Import class name

Example:

Import com.MD5

String strMd5 = MD5.GetMD5Code ("123456")

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report