I have deployed my java application on a Solaris system.A network printer is connected to this Solaris machine.And from within the java application I am firing a print using Java's Print API. I am printing a GIF document.But the printer outputs junk characters onto the pages.When the same thing is done on an application deployed on a Windows system and print is fired to a printer attached to this Windows system it prints properly. Can someone advise me on what would be the problem and how to rectify it?
Well I am not aware of what XWindows is and what is it's purpose in a Solaris System.Can you please tell me?Also can someone please let me know what would be any other probable reason because of which I am facing the problem?
I am not sure if whether the system has a Graphical Display matters.All I am doing is deploying a Java application as a jar in the Solaris Server.Now when the application is run it fires a print to a Nwtwork Printer through the Java Print API.All this is done without using any GUI or Swing application which would require manual selections. Here everything is done without manual intervention at all.The application gets the list of printservices configured for the Server and fires the print to the designated printer.The same application deployed on Windows works fine and my GIF document gets printed properly on the printer.But with the application deployed on Solaris the printer spews out junk characters when GIF document is printed.I just need to know how to circumvent this problem.
Originally posted by Nikhil Sun: I am not sure if whether the system has a Graphical Display matters.
Printing requires a graphical environment to render graphics on a virtual "page" to send to the printer. Windows always has a graphical environment (hence the name). On a Unix variant like Solaris, the graphical environment is an optional component. As for how to circumvent this problem, see the links I posted in my original reply (it may be as easy as setting the system property "-Djava.awt.headless= true" on your server). [ June 20, 2008: Message edited by: Joe Ess ]
I see that Xvfb is there on the Solaris system.I also set the System property java.awt.headless as true inside my application. Inspite of this when I try and print I am getting the following Exception when I try to print a txt file:
java.awt.print.PrinterException: Printer is not accepting job. 2008-07-02 13:15:57.108 [info] at sun.print.RasterPrinterJob.print(RasterPrinterJob.java:1231) 2008-07-02 13:15:57.108 [info] at sun.print.RasterPrinterJob.print(RasterPrinterJob.java:1197) 2008-07-02 13:15:57.108 [info] at nia.ps.engine.runtime.printer.TextPrinter.doPrint(TextPrinter.java:216) 2008-07-02 13:15:57.108 [info] at nia.ps.engine.runtime.printer.TextPrinter.print(TextPrinter.java:177) 2008-07-02 13:15:57.108 [info] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 2008-07-02 13:15:57.108 [info] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 2008-07-02 13:15:57.108 [info] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 2008-07-02 13:15:57.108 [info] at java.lang.reflect.Method.invoke(Method.java:585) 2008-07-02 13:15:57.108 [info] at nia.ps.engine.runtime.dispatcher.PrintDispatcher.printDocs(PrintDispatcher.java:141) 2008-07-02 13:15:57.108 [info] at nia.ps.engine.runtime.dispatcher.PrintDispatcher.process(PrintDispatcher.java:85) 2008-07-02 13:15:57.108 [info] at nia.ps.engine.runtime.dispatcher.PrintDispatcher.prepareToPrint(PrintDispatcher.java:48) 2008-07-02 13:15:57.108 [info] at nia.ps.engine.runtime.dispatcher.PrintDispatcher.firePrint(PrintDispatcher.java:27) 2008-07-02 13:15:57.108 [info] at nia.ps.engine.PrintEngine.runJob(PrintEngine.java:44) 2008-07-02 13:15:57.108 [info] at nia.ps.engine.PrintEngine.spooler_process(PrintEngine.java:65)
I haven't been able to solve the problem yet.I deployed my application again on a Solaris system.Using printmgr I configured a network printer on this system.Till here things are good.then when my Java application(which uses Java Print Service API) runs the call to printer seems to occur but printing(of a GIF file for example) doesn't happen.There is no error though now. Also when I directly give the unix command lp -d hplj file.gif it works and the gif document gets printed. Why doesn't print call from within Java work? I need to crack this as I am working towards production deployment but I am stuck p for qite some time because of this.