我需要在虚拟服务器上启动jperf。我通过ssh配置了x11转发。xclock-正在工作。但如果我启动JPERF,我会得到:
user@client-32:~/sandbox/jperf-2.0.2$ sh jperf.sh Exception in thread "main" java.lang.ExceptionInInitializerError Caused by: java.awt.HeadlessException at sun.java2d.HeadlessGraphicsEnvironment.getDefaultScreenDevice(HeadlessGraphicsEnvironment.java:77) at net.nlanr.jperf.JPerf.(Unknown Source)
java version:
java version "1.7.0_03" OpenJDK Runtime Environment (IcedTea7 2.1.1pre) (7~u3-2.1.1~pre1-1ubuntu3) OpenJDK Client VM (build 22.0-b10, mixed mode, sharing)
uname -a :
`Linux client-32 3.2.0-29-generic-pae #46-Ubuntu SMP Fri Jul 27 17:25:43 UTC 2012 i686 i686 i386 GNU/Linux
Problem solved
Need to add -Djava.awt.headless=true
into jperf.sh should be like this:
#!/bin/sh
java -classpath jperf.jar:lib/forms-1.1.0.jar:lib/jcommon-1.0.10.jar:lib/jfreechart-1.0.6.jar:lib/swingx-0.9.6.jar net.nlanr.jperf.JPerf -Djava.awt.headless=true
最佳答案
您应该在无头模式下运行jperf,因为您可能需要编辑jperf.sh,请参见:
http://javatechniques.com/blog/linux-x11-libraries-for-headless-mode/
如果仍然不起作用,请尝试使用oracle jvm而不是openjdk one。