JDK-4683270 : Start supporting CUPS printing in Linux JDK
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2002-05-10
  • Updated: 2003-08-11
  • Resolved: 2003-08-11
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 Availabitlity Release.

To download the current JDK release, click here.
Other
5.0 tigerFixed
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
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger FIXED IN: tiger INTEGRATED IN: tiger tiger-b15
2004-06-14

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

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