Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4707777
Votes 47
Synopsis JPS only prints to default printer on Solaris 8.
Category java:classes_2d
Reported Against 1.4 , 1.4.1
Release Fixed 1.4.2(mantis-b10)
State 10-Fix Delivered, bug
Priority: 4-Low
Related Bugs 4822274
Submit Date 25-JUN-2002
Description
description: FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)


FULL OPERATING SYSTEM VERSION :
SunOS brubert 5.8 Generic_108528-12 sun4u sparc SUNW,Ultra-1

ADDITIONAL OPERATING SYSTEMS :
Red Hat Linux 7.2, and I suspect all Unix flavors
error dos _not_ occur in Windows


EXTRA RELEVANT SYSTEM CONFIGURATION :
In my environment it was any network printer, all were non
IPP.

A DESCRIPTION OF THE PROBLEM :
JPS (javax.print.*) will only print to the system default
printer.
This leads me to suspect that java internally is calling
the posix "lp" printing command without utilizing the -d
option to lp.

Correct me if I am wrong, but you setup the default printer
by doing one of the following:
1.) LPDEST or PRINTER environment variable settings
2.) _default destination in $HOME/.printers
3.) _default destination in /etc/printers.conf
4.) _default destination in FNS

If none of the above are set, then JPS will print nothing.

If one of the above are set, then JPS will only print to
that default printer, even if you specify a different one
in JPS.

EXPECTED VERSUS ACTUAL BEHAVIOR :
When selecting a non-default printer I would expect that
non-default printer to pruduce my output, but the default
printer was the one that printed it instead, no matter what
printer I chose.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. identify your default printer, by the following command:
lpstat -d
2. identify an xxxxx  printer on your system, by the
following command: lpstat -s
3. ensure that you can print to both printers from steps 1
and 2 by issuing the command: echo "DOES THIS PRINT" |lp -d
PRINTER_NAME
4. create a postscript file named "example.ps"
5. in the same step as number 4., compile and run the
attached program (with jdk1.4 of course) and select the non-
default printer identified in step 2.

---------- BEGIN SOURCE ----------
import java.io.*;
import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
import javax.print.event.*;

public class PrintPS {

    public static void main(String args[]) {
        PrintPS ps = new PrintPS();
    }

    public PrintPS() {
        DocFlavor flavor = DocFlavor.INPUT_STREAM.POSTSCRIPT;
        PrintRequestAttributeSet aset =
            new HashPrintRequestAttributeSet();
        aset.add(MediaSizeName.ISO_A4);

        /* locate a print service that can handle it */
        PrintService[] pservices =
            PrintServiceLookup.lookupPrintServices(flavor, aset);
        if (pservices.length > 0) {

            /* create a print job for the chosen service */
            PrintService pserv = ServiceUI.printDialog(null, 50, 50,
pservices,
                    null, flavor, aset);
            //DocPrintJob pj = pservices[0].createPrintJob();
            DocPrintJob pj = pserv.createPrintJob();
            try {
                FileInputStream fis = new FileInputStream("example.ps");
                Doc doc = new SimpleDoc(fis, flavor, null);

                /* print the doc as specified */
                pj.print(doc, aset);

            } catch (IOException ie) {
                System.err.println(ie);
            } catch (PrintException e) {
                System.err.println(e);
            }
        }
    }
}

---------- END SOURCE ----------
Work Around
N/A
Evaluation
The UnixPrintJob implementation is constructed from the correct UnixPrintService
implementation. However the printer name is not copied from the service to
the job so the destination field is left empty, so it spools to the default printer. The fix is simple - just copy the printer name from the service to
the destination variable of the job.

 xxxxx@xxxxx  2002-12-02
============================
Comments
  
  Include a link with my name & email   

Submitted On 12-NOV-2002
gholmer
This code fails under SuSE Linux 8.1 as well (i.e. goes to
default printer instead of printer specified in dialog).


Submitted On 18-NOV-2002
ramboid
This code fails in Linux RedHat v7.2 and v7.3.  I reported this 
as bug and so far I got an internal review ID of: 166979.

A work aorund that is working for me is to run the program 
from a Linux shell which sets the variables PRINTER, LPDEST,a 
nd NPRINTER to the printer to which I desire the printing to 
go.  The java API thinks that the printer in the shell variables 
is the default printer and the printing goes to it


Submitted On 21-NOV-2002
bachmanna
I need that you fix this ASAP, please !!!!!!


Submitted On 21-NOV-2002
RuizH
I need that you fix this ASAP, please !!!!!!


Submitted On 21-NOV-2002
teresaa
This fix is critical to our operations.  Add me to the list of 
anxiously awaiting users.  Otherwise, good job on the API!


Submitted On 21-NOV-2002
besd2173
I need that you fix this ASAP, please !!!!!!


Submitted On 21-NOV-2002
EDilena
io


Submitted On 27-NOV-2002
vtarasov
I need that you fix this ASAP, please !!!!!!


Submitted On 14-JAN-2003
opsedv
This bug is "closed, fixed", but i do have the same problem 
with "j2sdk 1.4.1_01" (OS: Linux).


Submitted On 15-JAN-2003
opsedv
Sorry, i have overseen the "mantis-beta" which would be 1.4.2


Submitted On 28-FEB-2003
ramboid
Where do I find the "mantis-beta" to correct this problem?


Submitted On 28-FEB-2003
ramboid
It seems that this bug has not been fixed for Linux RedHat 
yet.  I downloaded and installed jdk 1.4.1_02 in Linux RedHat 
and the bug persists.  That is, printing is allways directed to 
the default printer of the server regardles of the printer 
service that is chosen in the ServiceUI screen


Submitted On 01-MAR-2003
Thiyagu24
I downloaded the New JDK 1.4.1_02 and tried to print the 
document to a specific printer under SUN Solaris 2.6. Its 
again going to the default Printer. 


Submitted On 04-MAR-2003
ramboid
jdk1.4.1_02 does not fix this problem in Linux RedHat and bug 
4707777 is not in the list of bug fixes for this release.  Where 
is mantis-beta?


Submitted On 18-MAR-2003
nlsleung222
how do u copy the printer name from the service to the 
destination var of the job? i need to specify the URI to it and 
i am figuring out HARD on how to do that??
any insights?


Submitted On 28-APR-2003
ifeldberg
How are we supposed to implement the workaround since:
1) sun.print.UnixPrintJob.java is not delivered in the JDK
2) the mDestination variable in it is PRIVATE
It's been 6 months - is anyone working on this?


Submitted On 29-APR-2003
jgodinez
This is fixed in 1.4.2 which is now available for download.



PLEASE NOTE: JDK6 is formerly known as Project Mustang