Skip to content
Advertisement

java application and x11 forwarding

I need to start jperf on virtual server. I configured X11 forwarding via ssh. xclock – is working. But if I start jperf I get:


    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

Advertisement

Answer

You should run jperf in headless mode, for that you may need to edit jperf.sh, see: http://javatechniques.com/blog/linux-x11-libraries-for-headless-mode/

if it’s still not working, try with oracle jvm instead of openjdk one.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement