Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Java Print Service API in Java Stored Procedure (Linux / Cups)

user502964Apr 15 2011
Hello teachers!
I'm having a problem to use a Java API for printing via the service Cups on Linux OS.
It turns out that the JAVA API (PrintServiceLookup) can not return the printers installed on the Linux CUPS service.
I found some people with the same problem but all without solution.
557852

Information on the Environment:
SO: Linux Read Hat ES 5.3 (64 bits / XEON quade core)
Oracle: 10.2.0.4

Code to test:

CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "ListPrinters"
AS import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;

public class ListPrinters {
public static String AvailablePrinters(){
String strList;
PrintService[] pservices =PrintServiceLookup.lookupPrintServices(null,null);
if (pservices.length > 0 )
strList = pservices[0].getName();
else
strList = "No printers found";
return strList;
}

public static String listprinters() throws Exception {
String listofprinters;
try {
SecurityManager sm = System.getSecurityManager();
if (sm != null) sm.checkPrintJobAccess();
}
catch (SecurityException ex) {
System.err.println("Sorry. Printing is not allowed.");
}

listofprinters = AvailablePrinters();
return listofprinters;
}
}
/

CREATE OR REPLACE
FUNCTION get_printer_test RETURN VARCHAR2 IS
LANGUAGE JAVA
NAME 'ListPrinters.listprinters() return String';
/

SELECT get_printer_test FROM DUAL
/


Thanks
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 13 2011
Added on Apr 15 2011
0 comments
1,116 views