Topic
  • 10 replies
  • Latest Post - ‏2006-07-03T02:52:44Z by SystemAdmin
SystemAdmin
SystemAdmin
4447 Posts

Pinned topic Do IBM 1.4 JRE's support java.awt.headless=true?

‏2004-02-18T03:28:58Z |
I'm using IBM's 1.4.1 VM on AIX, and it throws a HeadlessException when I try to perform certain operations on a JLabel.
I'm starting the VM with -Djava.awt.headless=true, but to no avail. I'm familiar with running server-side java in headless environments, using the Java 1.4 headless option, as well as with versions of Java < 1.4 using alternate graphics libraries (like PJA), and have been doing so on other platforms for quite some time. I'm not familiar with using the headless option on an IBM 1.4 VM - I haven't needed to until WebSphere 5.1. If the headless option isn't supported, does anyone know how to get an IBM VM to run headlessly on AIX? The problem also exists on Linux using IBM VM's.

Here are some details of the VM, the HeadlessException, and a sample test case. Notice that the test case only tries to getPreferredSize of the JLabel - it doesn't try to render it:

//-------java -version output
codejava version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1)
Classic VM (build 1.4.1, J2RE 1.4.1 IBM AIX build ca1411-20030930 (JIT enabled: jitc))[/code]

//---------code
code] public static void main(String args[)
{
JLabel label = new JLabel();
Dimension dim = label.getPreferredSize();
System.out.println(dim);
}
[/code]
//---------Exception
codeException in thread "main" java.awt.HeadlessException
at sun.java2d.HeadlessGraphicsEnvironment.getDefaultScreenDevice(HeadlessGraphicsEnvironment
.java:98)
at sun.awt.font.FontDesignMetrics.createDefaultFrc(FontDesignMetrics.java:152)
at sun.awt.font.FontDesignMetrics.<init>(FontDesignMetrics.java:170)
at sun.awt.SunToolkit.getFontMetrics(SunToolkit.java:451)
at sun.awt.motif.MToolkit.getFontMetrics(MToolkit.java:441)
at sun.awt.HeadlessToolkit.getFontMetrics(HeadlessToolkit.java:396)
at javax.swing.plaf.basic.BasicLabelUI.getPreferredSize(BasicLabelUI.java:229)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1300)
[/code]
Updated on 2006-07-03T02:52:44Z at 2006-07-03T02:52:44Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    4447 Posts

    Re: Do IBM 1.4 JRE's support java.awt.headless=true?

    ‏2004-02-18T04:48:42Z  
    You may want to ensure that your DISPLAY environment variable points to a machine where X11 library is installed.

    Govind Seshadri
  • SystemAdmin
    SystemAdmin
    4447 Posts

    Re: Do IBM 1.4 JRE's support java.awt.headless=true?

    ‏2004-04-23T17:57:58Z  
    You may want to ensure that your DISPLAY environment variable points to a machine where X11 library is installed.

    Govind Seshadri
    Govind, his question is does the IBM JRE support the java.awt.headless=true option for [b]headless[/b] operation -- that is, [b]without[/b] X-window libraries installed. See http://today.java.net/pub/a/today/2004/04/22/images.html for more details. I also have a need for this to work, so an answer is appreciated.
  • SystemAdmin
    SystemAdmin
    4447 Posts

    Re: Do IBM 1.4 JRE's support java.awt.headless=true?

    ‏2004-04-26T02:50:23Z  
    Govind, his question is does the IBM JRE support the java.awt.headless=true option for [b]headless[/b] operation -- that is, [b]without[/b] X-window libraries installed. See http://today.java.net/pub/a/today/2004/04/22/images.html for more details. I also have a need for this to work, so an answer is appreciated.
    I believe that the headless operation is indeed supported under the IBM 1.4.1 VM pn AIX. (I do not have official confirmation of this...I will post it as soon as I receive it...thanks for your patience!) However, I believe you should also be able to use PJA for this purpose. There is some extra configuration required, as explained by this good pointer: http://lists.isb.sdnpk.org/pipermail/comp-list/2002-September/001276.html

    Govind Seshadri
  • SystemAdmin
    SystemAdmin
    4447 Posts

    Re: Do IBM 1.4 JRE's support java.awt.headless=true?

    ‏2004-06-07T21:34:16Z  
    I believe that the headless operation is indeed supported under the IBM 1.4.1 VM pn AIX. (I do not have official confirmation of this...I will post it as soon as I receive it...thanks for your patience!) However, I believe you should also be able to use PJA for this purpose. There is some extra configuration required, as explained by this good pointer: http://lists.isb.sdnpk.org/pipermail/comp-list/2002-September/001276.html

    Govind Seshadri
    I got the same problem with HeadlessException when using a thirdparty library to generate the image file(not running any frame or applet). I also tried to use eteks graphics environment when starting JVM and I got NPE like this. Does any one has any idea?

    Thanks,
    gvu.

    Exception in thread "main" java.lang.NullPointerException
    at java.awt.EventQueue.isDispatchThread(EventQueue.java:729)
    at javax.swing.SwingUtilities.isEventDispatchThread(SwingUtilities.java:
    1243)
    at javax.swing.JComponent.revalidate(JComponent.java:4502)
    at ilog.views.chart.IlvChart$AxisElement.a(Unknown Source)
    at ilog.views.chart.IlvChart.setXScale(Unknown Source)
    at ilog.views.chart.IlvChart.a(Unknown Source)
    at ilog.views.chart.IlvChartConfig.a(Unknown Source)
    at ilog.views.chart.IlvChartConfig.a(Unknown Source)
    at ilog.views.chart.IlvChart.a(Unknown Source)
    at ilog.views.chart.IlvChart.<init>(Unknown Source)
    at ilog.views.chart.IlvChart.<init>(Unknown Source)
    at ilog.views.chart.IlvChart.<init>(Unknown Source)
  • SystemAdmin
    SystemAdmin
    4447 Posts

    Re: Do IBM 1.4 JRE's support java.awt.headless=true?

    ‏2004-06-08T14:43:26Z  
    You may want to ensure that your DISPLAY environment variable points to a machine where X11 library is installed.

    Govind Seshadri
    I am using this feature with IBM JVM 1.4.1 SR2 on Linux SuSE 9.0 without a graphics environment, but I had to install X11. You don't need to start the X11 service, but the binaries must be present on your system.

    I installed X11 using this command:

    yast2 –i XFree86

    The I use this property to activate headless:

    -Djava.awt.headless=true

    For more information you may want to check this article, page 18:

    http://www.martincordova.com/docs/suse-install.pdf

    Regards,
    Martin Cordova

    Dinamica - J2EE Framework
    Free, Easy and Powerful
    http://www.martincordova.com
  • SystemAdmin
    SystemAdmin
    4447 Posts

    Re: Do IBM 1.4 JRE's support java.awt.headless=true?

    ‏2004-06-09T16:54:33Z  
    I am using this feature with IBM JVM 1.4.1 SR2 on Linux SuSE 9.0 without a graphics environment, but I had to install X11. You don't need to start the X11 service, but the binaries must be present on your system.

    I installed X11 using this command:

    yast2 –i XFree86

    The I use this property to activate headless:

    -Djava.awt.headless=true

    For more information you may want to check this article, page 18:

    http://www.martincordova.com/docs/suse-install.pdf

    Regards,
    Martin Cordova

    Dinamica - J2EE Framework
    Free, Easy and Powerful
    http://www.martincordova.com
    Actually, the bug is in the thirdparty packages which do something and those operations are not support in headless mode. I just overrided some classes and it's fixes.
    Thanks,
    gvu
  • SystemAdmin
    SystemAdmin
    4447 Posts

    Re: Do IBM 1.4 JRE's support java.awt.headless=true?

    ‏2004-08-27T20:06:03Z  
    Actually, the bug is in the thirdparty packages which do something and those operations are not support in headless mode. I just overrided some classes and it's fixes.
    Thanks,
    gvu
    > Actually, the bug is in the thirdparty packages which
    > do something and those operations are not support in
    > headless mode. I just overrided some classes and it's
    > fixes.
    > Thanks,
    > gvu

    With what did you replace the offending method calls? I'm getting the HeadlessException when calling JComponent.getMinimumSize() and JComponent.getPreferredSize().
  • SystemAdmin
    SystemAdmin
    4447 Posts

    Re: Do IBM 1.4 JRE's support java.awt.headless=true?

    ‏2004-09-16T15:25:25Z  
    Actually, the bug is in the thirdparty packages which do something and those operations are not support in headless mode. I just overrided some classes and it's fixes.
    Thanks,
    gvu
    > Actually, the bug is in the thirdparty packages which
    > do something and those operations are not support in
    > headless mode. I just overrided some classes and it's
    > fixes.
    > Thanks,
    > gvu

    Can you or anyone else here tell me how to work around this problem. We are running into the same NullPointerException (see below) running WebSphere 5.1.1 with Java 1.4.2 using PJA 2.5 and JClass ServerViews. This all worked fine on WebSphere 5.1 with Java 1.3.1, but the WebSphere upgrade has broken this.

    What methods in which classes did you override ?

    Thanks in advance for any information that would help us get around this.

    java.lang.NullPointerException
    at java.awt.EventQueue.isDispatchThread(EventQueue.java:732)
    at javax.swing.SwingUtilities.isEventDispatchThread(SwingUtilities.java:1269)
    at javax.swing.JComponent.revalidate(JComponent.java:4513)
    at javax.swing.JComponent.setVisible(JComponent.java:2278)
    at com.tivoli.itmnp.jctest.FnpJctestChart.<init>(FnpJctestChart.java:125)

    Jim Fowler
  • SystemAdmin
    SystemAdmin
    4447 Posts

    Re: Do IBM 1.4 JRE's support java.awt.headless=true?

    ‏2006-03-03T23:38:45Z  
    Govind, his question is does the IBM JRE support the java.awt.headless=true option for [b]headless[/b] operation -- that is, [b]without[/b] X-window libraries installed. See http://today.java.net/pub/a/today/2004/04/22/images.html for more details. I also have a need for this to work, so an answer is appreciated.

    URGENT

    I'm also running into this problem(headless exception), does anyone have the confirmation to the subject question.
    Thanks in Advance.
  • SystemAdmin
    SystemAdmin
    4447 Posts

    Re: Do IBM 1.4 JRE's support java.awt.headless=true?

    ‏2006-07-03T02:52:44Z  
    I am using this feature with IBM JVM 1.4.1 SR2 on Linux SuSE 9.0 without a graphics environment, but I had to install X11. You don't need to start the X11 service, but the binaries must be present on your system.

    I installed X11 using this command:

    yast2 –i XFree86

    The I use this property to activate headless:

    -Djava.awt.headless=true

    For more information you may want to check this article, page 18:

    http://www.martincordova.com/docs/suse-install.pdf

    Regards,
    Martin Cordova

    Dinamica - J2EE Framework
    Free, Easy and Powerful
    http://www.martincordova.com
    I know this is an old thread, but wondered if someone could confirm.

    We are running Websphere 5.1 on RHEL4. I've tried the following code:

    System.setProperty("java.awt.headless", "true");
    Toolkit tk = Toolkit.getDefaultToolkit();

    But always get this exception:
    7/3/06 12:09:14:346 EST 7b604368 WebGroup E SRVE0026E: Servlet Error-[Can't connect to X11 window server using ':0.
    0' as the value of the DISPLAY variable.]: java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value
    of the DISPLAY variable.
    at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
    at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:175)
    at java.lang.Class.forName1(Native Method)
    at java.lang.Class.forName(Class.java(Compiled Code))
    at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:91)
    at sun.awt.motif.MToolkit.<clinit>(MToolkit.java:124)
    at java.lang.Class.forName1(Native Method)
    at java.lang.Class.forName(Class.java(Compiled Code))
    at java.awt.Toolkit$2.run(Toolkit.java:796)
    at java.security.AccessController.doPrivileged1(Native Method)
    at java.security.AccessController.doPrivileged(AccessController.java(Compiled Code))
    at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:787)
    To check for X11 on the box, I tried:
    rpm -qa | grep -i Xfree

    ... but it wasnt there. Can I get our infratstructure people to JUST install Xvfb ? or will they need to install the full X11 ?

    Once we install either of these, do we still need to set the DISPLAY variable ?