I can print using java print api from an application but service lookup fails in an applet?
As a matter of fact
PrintService printService = PrintServiceLookup.lookupDefaultPrintService();
If it is possible can anybody give me a sample of working code?
A PrintServiceLookup implementor is recommended to check for the SecurityManager.checkPrintJobAccess() to deny access to untrusted code. Following this recommended policy means that untrusted code may not be able to locate any print services. Downloaded applets are the most common example of untrusted code.