public class CreateImage { public static void main(String[] args) throws Exception { int width = 250; int height = 100; String s = "javax.servlet.http.HttpServletRequest"; File file = new File("c:/image.jpg"); BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics g = (Graphics) bi.getGraphics(); g.setColor(Color.white); g.fillRect(0, 0, width, height); g.setColor(Color.blue); g.drawString(s,10,30); ImageIO.write(bi, "jpg", file); } }