• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Printing in Unix

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is the Solaris system running Xwindows?
I had to install Xvfb to get headless mode to work on my Solaris servers for JDK 1.4.
Here is a more recent article on headless mode under Java 6.
 
Nikhil Sun
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wiki entry for Xwindows
Do you have a graphical display on this machine or do you just have a command line?
 
Nikhil Sun
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ]
 
Nikhil Sun
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)

Any clues friends??
 
Nikhil Sun
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can someone help me with this issue?
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you using CUPS? There's a problem with CUPS changing the way they use sockets.
 
Nikhil Sun
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 129
1
Oracle Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nikhil,
Did you resolve the issue. The same happens here. Printing is done but it prints only Junk characters. Any resolution??
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What encoding are you using?
 
karthik Suryanarayanan
Ranch Hand
Posts: 129
1
Oracle Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Campbell,
I have been using the following code ..


I'm not specifically using any encoding. Just have run this class in Unix server(HP-UX). Printer is EPSON LQ-690 ESC/P2 and is connected to my Unix server. I have already raised this in https://coderanch.com/t/556410/java/java/Printing-data-Java-Linux-Unix
 
There will be plenty of time to discuss your objections when and if you return. The cargo is this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic