Find the answer to your Linux question:
Results 1 to 2 of 2
Hi all, I m using RedHat Linux 9 as OS, i use the following code to creat a WBMP image, ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// import java.awt.*; import java.awt.geom.*; import java.awt.image.*; import java.awt.font.*; import ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2004
    Posts
    1

    Problem in Creating image in Linux Run Level-3


    Hi all,

    I m using RedHat Linux 9 as OS, i use the following code to creat a WBMP image,
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.image.*;
    import java.awt.font.*;
    import javax.imageio.*;
    import java.io.*;
    import javax.media.jai.*;

    public class Createlogo
    {
    Createlogo ()
    {
    try
    {
    Font cachedFont = new Font ( "Arial", 1, 1 );
    cachedFont = cachedFont.deriveFont ( ( float ) 9 );
    BufferedImage im = new BufferedImage ( 72, 14, BufferedImage.TYPE_BYTE_BINARY );
    Graphics2D graphics = im.createGraphics ();
    graphics.setBackground ( new Color ( 0xff, 0xff, 0xff ) );
    graphics.setColor ( new Color ( 0, 0, 0 ) );
    graphics.clearRect ( 0, 0, 72, 14 );
    graphics.setFont ( cachedFont );
    FontRenderContext frc = graphics.getFontRenderContext ();
    TextLayout layout = new TextLayout ( "Java", cachedFont, frc );
    Rectangle2D bounds = layout.getBounds ();
    FontMetrics fm = graphics.getFontMetrics ();

    layout.draw ( graphics, ( float ) Math.floor ( ( 72 - bounds.getMaxX () ) / 2 ), fm.getMaxAscent () );

    JAI.create ( "filestore", im, "/home/oracle/Java/img.wbmp", "wbmp" );
    }
    catch(Exception e)
    {
    System.out.println(e);
    }
    }

    public static void main(String[] args)
    {
    Createlogo cl = new Createlogo();
    }
    }
    /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    It is working very well in Level-5 and creating image but when i change run level to 3, and restart the system in run level 3, the following exception appears on execution of -> java Createlogo

    Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.

    Please tell me how i can sucessfully create image using run level 3.

    Thanks in advance...

  2. #2
    Linux Engineer
    Join Date
    Sep 2003
    Location
    Knoxhell, TN
    Posts
    1,078
    the problem is this: that program is dependent upon X... you have to be running an X server for it to work... i think that is how it works with most graphical programs unless you have it set up to work in framebuffer mode.... once in runlevel 3, if you type 'startx' (w/o quotes) at the prompt, it will start X again without changing you current runlevel... you can then do what you have to in X and then shut X down and go back to a prompt instead of a DM....
    Their code will be beautiful, even if their desks are buried in 3 feet of crap. - esr

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •