Skip to Content
Former Member
Aug 27, 2007 at 08:00 AM

Java Printing to Network Printer Problem



I'm trying to print some data to the default network printer of the Netweaver AS (Windows 2003 Server) in the LAN. Unfortunately, it <b>cannot</b> detect the default network printer. Meanwhile, another try of the same coding in the same server using standalone JVM <b>can</b> detect the default network printer.

1. I suspected that this can be due to the SAP user which running the services in the WAS does not have the right to the printing service. Can anymore shed some lights on this?

2. In the actual production with load-balancing and clustering etc, do i still need to configure each and every server to have my desired printer as default printer?

DocFlavor flavor = DocFlavor.INPUT_STREAM.POSTSCRIPT;
		PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
		aset.add(new Copies(1));
		PrintService[] prnSvcs;
	    PrintService prnSvc = PrintServiceLookup.lookupDefaultPrintService();
	    if (prnSvc != null){
	    	 System.out.println("Default Printer found: ["+prnSvc.getName()+"]");
	          prnSvcs = PrintServiceLookup.lookupPrintServices(flavor, aset);
	          if (prnSvcs.length > 0)
	              int ii = 0;
	              while ( ii < prnSvcs.length )
	            	  System.out.println("Printer found: ["+prnSvcs[ii].getName()+"]");

Any help would be much appreciated. Thanks.

- julius