United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4683270 Start supporting CUPS printing in Linux JDK
JDK-4683270 : Start supporting CUPS printing in Linux JDK

Details
Type:
Enhancement
Submit Date:
2002-05-10
Status:
Resolved
Updated Date:
2003-08-11
Project Name:
JDK
Resolved Date:
2003-08-11
Component:
client-libs
OS:
linux
Sub-Component:
2d
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.0
Fixed Versions:
5.0 (tiger)

Related Reports

Sub Tasks

Description
Currently printing uses BSD commands on Linux.  That only provides
very limited options in combination with CUPS's BSD compatibility
layer:

E.g. I have one printer named brother.  It has a default instance for
normal one-sided printing and two additional instances for for duplex
printing and two-sides-on-one duplex printing.

     % lpstat -d -v
     system default destination: brother/duplex
     device for brother: ipp://192.168.1.20:631/ipp
     device for brother/duplex: ipp://192.168.1.20:631/ipp
     device for brother/papers: ipp://192.168.1.20:631/ipp

The current J2SE code only see one printer on Linux (Solaris should be
OK because it uses SYSV commands):

     % java ListCUPSDestinations[1]
     Unix Printer : brother

With a few modifications[2] I get better results:

     % java ListCUPSDestinations
     Unix Printer : brother/duplex
     Unix Printer : brother
     Unix Printer : brother/duplex
     Unix Printer : brother/papers

                                    

Comments
EVALUATION

We will support this for 1.5.
###@###.### 2003-02-13

With the fix, the output would look like:
% java ListCUPSDestinations
     IPP Printer : brother/duplex
     IPP Printer : brother     
     IPP Printer : brother/papers

"IPP Printer" means that the printer has been queried using HTTP/IPP communication.

###@###.### 2003-07-23
=====================================
                                     
2003-07-23
SUGGESTED FIX

[1]  
,----[ ListCUPSDestinations.java ]
| import java.awt.print.*;
| import javax.print.*;
| 
| public class ListCUPSDestinations
| {
|     public static void main(String[] args) 
|     {
|         PrintService[] services = PrinterJob.lookupPrintServices();
|         for (int i = 0; i < services.length; i++) {
|             System.out.println(services[i]);
|         }
|     }
| }
`----

[2]  

,----
| Index: UnixPrintServiceLookup.java
| ===================================================================
| RCS file:
/var/jdk12/jdk/j2se1.4/src/solaris/classes/sun/print/UnixPrintServiceLookup.java,v
| retrieving revision 1.1.1.3
| diff -u -u -r1.1.1.3 UnixPrintServiceLookup.java
| --- UnixPrintServiceLookup.java       7 Mar 2002 02:55:35 -0000       1.1.1.3
| +++ UnixPrintServiceLookup.java       10 May 2002 03:32:56 -0000
| @@ -50,14 +50,25 @@
|      private Vector lookupListeners = null;
|  
|      static String osname;
| +    static boolean isCUPS;
| +    static boolean useBinSh;
|  
|      static {
|          osname = (String)java.security.AccessController.doPrivileged(
|              new sun.security.action.GetPropertyAction("os.name"));
| +
| +        if ("Linux".equals(osname)) {
| +            String command = "/usr/bin/lpstat -r | grep 'is running'";
| +            String[] answer = execCmd(command);
| +            if (answer != null && answer.length > 0) {
| +                isCUPS = true;
| +                useBinSh = true;
| +            }
| +        }
|      }
|  
|      static boolean isSysV() {
| -     return osname.equals("SunOS");
| +     return isCUPS || osname.equals("SunOS");
|      }
|    
|      static boolean isBSD() {
| @@ -437,7 +448,7 @@
|  
|       try {
|              final String[] cmd = new String[3];
| -         if (isSysV()) {
| +         if (isSysV() && !useBinSh) {
|               cmd[0] = "/usr/bin/sh";
|               cmd[1] = "-c";
|               cmd[2] = "env LC_ALL=C " + command;
`----
                                     
2004-06-11
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
tiger

FIXED IN:
tiger

INTEGRATED IN:
tiger
tiger-b15


                                     
2004-06-14



Hardware and Software, Engineered to Work Together