| 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... |