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;
`----
|