当我运行 Jmeter 时出现错误 -
An error occurred:
No X11 DISPLAY variable was set,
or no headful library support was found,
but this program performed an operation which requires it,
但是我的变量是 SET。 显示变量
2022-12-02 14:38:39,871 INFO o.a.j.u.JMeterUtils: Setting Locale to en_EN
2022-12-02 14:38:39,885 INFO o.a.j.JMeter: Loading user properties from: user.properties
2022-12-02 14:38:39,885 INFO o.a.j.JMeter: Loading system properties from: system.properties
2022-12-02 14:38:39,890 INFO o.a.j.JMeter: Copyright (c) 1998-2022 The Apache Software Foundation
2022-12-02 14:38:39,890 INFO o.a.j.JMeter: Version 5.5
2022-12-02 14:38:39,890 INFO o.a.j.JMeter: java.version=19.0.1
2022-12-02 14:38:39,890 INFO o.a.j.JMeter: java.vm.name=OpenJDK 64-Bit Server VM
2022-12-02 14:38:39,890 INFO o.a.j.JMeter: os.name=Linux
2022-12-02 14:38:39,890 INFO o.a.j.JMeter: os.arch=amd64
2022-12-02 14:38:39,890 INFO o.a.j.JMeter: os.version=5.15.0-56-generic
2022-12-02 14:38:39,890 INFO o.a.j.JMeter: file.encoding=UTF-8
2022-12-02 14:38:39,890 INFO o.a.j.JMeter: java.awt.headless=null
2022-12-02 14:38:39,890 INFO o.a.j.JMeter: Max memory =1073741824
2022-12-02 14:38:39,890 INFO o.a.j.JMeter: Available Processors =8
2022-12-02 14:38:39,897 INFO o.a.j.JMeter: Default Locale=English (EN)
2022-12-02 14:38:39,897 INFO o.a.j.JMeter: JMeter Locale=English (EN)
2022-12-02 14:38:39,897 INFO o.a.j.JMeter: JMeterHome=/home/ankur/software/jmeter/apache-jmeter-5.5
2022-12-02 14:38:39,897 INFO o.a.j.JMeter: user.dir =/home/ankur/software/jmeter/apache-jmeter-5.5/bin
2022-12-02 14:38:39,898 INFO o.a.j.JMeter: PWD =/home/ankur/software/jmeter/apache-jmeter-5.5/bin
2022-12-02 14:38:39,898 INFO o.a.j.JMeter: IP: 127.0.1.1 Name: ankur FullName: ankur
2022-12-02 14:38:39,904 INFO o.a.j.JMeter: Loaded icon properties from org/apache/jmeter/images/icon.properties
2022-12-02 14:38:40,004 INFO o.a.j.JMeterGuiLauncher: Setting LAF to: com.github.weisj.darklaf.DarkLaf:com.github.weisj.darklaf.theme.DarculaTheme
2022-12-02 14:38:40,147 ERROR o.a.j.JMeter: An error occurred:
java.awt.HeadlessException:
No X11 DISPLAY variable was set,
or no headful library support was found,
but this program performed an operation which requires it,
at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:166) ~[?:?]
at java.awt.Window.<init>(Window.java:553) ~[?:?]
at java.awt.Frame.<init>(Frame.java:428) ~[?:?]
at java.awt.Frame.<init>(Frame.java:393) ~[?:?]
at javax.swing.SwingUtilities$SharedOwnerFrame.<init>(SwingUtilities.java:1919) ~[?:?]
at javax.swing.SwingUtilities.getSharedOwnerFrame(SwingUtilities.java:1995) ~[?:?]
at javax.swing.JDialog.<init>(JDialog.java:276) ~[?:?]
at javax.swing.JDialog.<init>(JDialog.java:210) ~[?:?]
at javax.swing.JDialog.<init>(JDialog.java:158) ~[?:?]
at org.apache.jmeter.SplashScreen.<init>(SplashScreen.java:52) ~[ApacheJMeter_core.jar:5.5]
at org.apache.jmeter.JMeterGuiLauncher.startGuiInternal(JMeterGuiLauncher.kt:87) ~[ApacheJMeter_core.jar:5.5]
at org.apache.jmeter.JMeterGuiLauncher.access$startGuiInternal(JMeterGuiLauncher.kt:47) ~[ApacheJMeter_core.jar:5.5]
at org.apache.jmeter.JMeterGuiLauncher$startGui$1$1.invokeSuspend(JMeterGuiLauncher.kt:67) ~[ApacheJMeter_core.jar:5.5]
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) ~[kotlin-stdlib-1.6.21.jar:1.6.21-release-334(1.6.21)]
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) ~[kotlinx-coroutines-core-jvm-1.6.1.jar:?]
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318) ~[?:?]
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773) ~[?:?]
at java.awt.EventQueue$4.run(EventQueue.java:720) ~[?:?]
at java.awt.EventQueue$4.run(EventQueue.java:714) ~[?:?]
at java.security.AccessController.doPrivileged(AccessController.java:399) ~[?:?]
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86) ~[?:?]
at java.awt.EventQueue.dispatchEvent(EventQueue.java:742) ~[?:?]
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) ~[?:?]
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124) ~[?:?]
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113) ~[?:?]
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109) ~[?:?]
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) ~[?:?]
at java.awt.EventDispatchThread.run(EventDispatchThread.java:90) ~[?:?]
答案1
该问题是由于您有多个 Java 版本造成的。
步骤 1:检查您拥有的版本 sudo dpkg --list | grep -i jdk 。如果您有打开的 JDK,也可以从软件中心卸载
第 2 步:删除 jdk sudo apt-get purge openjdk*
步骤3:在命令行中运行java -version,你将看到没有安装程序
步骤4:安装sudo apt-get install openjdk-8-jre
JMeter 现在应该可以工作了。
答案2
此特定问题似乎是因为DISPLAY
未设置环境变量。可以使用以下命令修复此问题
export DISPLAY=:0
您可以检查它是否正常工作
echo $DISPLAY
# you should see :0
奖励答案
但如果你真正遇到的问题更像是
An error occurred: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable
解决方案可能是确保您使用的机器上有 x11 套接字可用。
在我的例子中,我尝试通过 docker 镜像运行 jmeter GUI。我可以通过确保主机和客户机共享一个可读写卷来实现这一点/tmp/.X11-unix:/tmp/.X11-unix