4 Replies Latest reply on Aug 10, 2006 12:16 AM by 843802

    java.awt.HeadlessException

    843799
      Hi, I am using JMF to try to stream video. I am using AVTransmit2, and it works ok in windows. When I install JMF on linux, I get the above exception, detailed below;
      java.awt.HeadlessException:
      No X11 DISPLAY variable was set, but this program performed an operation which requires it.
      javax.media.NoProcessorException: Error instantiating class: com.sun.media.processor.unknown.Handler : java.awt.HeadlessException:
      No X11 DISPLAY variable was set, but this program performed an operation which requires it.
              at javax.media.Manager.createProcessorForSource(Manager.java:1755)
              at javax.media.Manager.createProcessor(Manager.java:666)
              at rtp.AVTransmit2.createProcessor(AVTransmit2.java:147)
              at rtp.AVTransmit2.start(AVTransmit2.java:81)
              at rtp.AVTransmit2.main(AVTransmit2.java:509)
      Error : Couldn't create processor
      I've downloaded the JMF source code from the sun site, but it doesnt contain the javax.media source.

      Can anyone tell me;
      A) can i get hold of the javax.media source?
      B) can I set the X11 variable? and how?
      C) whats teh difference between the windows JMF and Linux JMF

      Thanks a lot.
      Rob
        • 1. Re: java.awt.HeadlessException
          843799
          Hi,

          If you want to see the media in liunux you need the X environment completely, and have a X session open!

          If you just want to stream it to another client, and the linux box is just a streaming server the following steps are neccessary:

          you need the BASIC X environment, then the virtual frame buffer Xvfb!
          start this Xvfb with a port number, eg.

          /usr/X11R6/bin/Xvfb :15 & (probably ar root on startup, only needed once)
          (:15 is just an example, :0 is the default, you just have to remember it for the following step:)

          before starting the java server process:

          DISPLAY=:15; export DISPLAY;

          Please note:
          the -Djava.awt.headless=true setting of java1.4 wasn't working in my server app in a JMF call:
          Manager.createProcessor(mediaURL);

          This caused a java.awt.HeadlessException + javax.media.NoProcessorException too!!!

          So it seems that JMF really NEEDS the X environment, headless isn't sufficient. On Windows the Graphic environment is installed always (=WINDOWS...) so no more graphcal environment is neccessary, a linux server could be installed completely without ANY graphical environment.... that's the difference!

          Gulpi
          • 2. Re: java.awt.HeadlessException
            843802
            Look like some java engineer thinks only inside his toolbox.. What's the business here with the Label? Why do you need to init it when its not even used!!! This is just another one of the reasons why JMF sucks so much.

            Exception occurred: java.awt.HeadlessException (to be caught at: javax.media.Man
            ager.createProcessorForSource(), line=1,752 bci=194)"thread=http-8500-Processor4
            ", java.awt.GraphicsEnvironment.checkHeadless(), line=121 bci=13

            http-8500-Processor4[1] where
            [1] java.awt.GraphicsEnvironment.checkHeadless (GraphicsEnvironment.java
            :121)
            [2] java.awt.Label.<init> (Label.java:133)
            [3] java.awt.Label.<init> (Label.java:100)
            [4] com.sun.media.BasicJMD.<init> (BasicJMD.java:41)
            [5] com.sun.media.PlaybackEngine.setSource (PlaybackEngine.java:163)
            [6] com.sun.media.MediaProcessor.setSource (MediaProcessor.java:32)
            [7] javax.media.Manager.createProcessorForSource (Manager.java:1,705)
            [8] javax.media.Manager.createProcessorForContent (Manager.java:1,579)
            [9] javax.media.Manager.createProcessor (Manager.java:627)
            [10] nu.datafuel.jmf.Transcode.a (unknown)
            • 3. Re: java.awt.HeadlessException
              843802
              to save you the hassel of downlaoding the source yourself the code looks like this

              static {
              try {
              Toolkit.getDefaultToolkit();
              } catch (Throwable t) {
              DEBUG = false;
              }
              ....

              if (DEBUG && jmd == null) {
              jmd = new BasicJMD(jmdTitle);


              so basically it is incompatible with java.awt.headless=true

              this code needs to check this system property. i guess that would help.
              • 4. Re: java.awt.HeadlessException
                843802
                FYI, I got around this problem by specifying the default toolkit as HeadlessToolkit by using -Dawt.toolkit=sun.awt.HeadlessToolkit