JDK-4707777 : JPS only prints to default printer on Solaris 8.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.4.0,1.4.1
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux,solaris,solaris_8
  • CPU: x86,sparc
  • Submitted: 2002-06-25
  • Updated: 2002-12-09
  • Resolved: 2002-12-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.2 b10Fixed
Related Reports
Duplicate :  
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 another 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 ----------

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mantis-beta FIXED IN: mantis-beta INTEGRATED IN: mantis-b10 mantis-beta
14-06-2004

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. ###@###.### 2002-12-02 ============================
02-12-2002