cancel
Showing results for 
Search instead for 
Did you mean: 

Java Printing to Network Printer Problem

Former Member
0 Kudos

Hi,

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(MediaSizeName.ISO_A4);
		aset.add(new Copies(1));
		PrintService[] prnSvcs;
	    PrintService prnSvc = PrintServiceLookup.lookupDefaultPrintService();
	    if (prnSvc != null){
	    	 System.out.println("Default Printer found: ["+prnSvc.getName()+"]");
	    }else{
	          prnSvcs = PrintServiceLookup.lookupPrintServices(flavor, aset);
	          
	          if (prnSvcs.length > 0)
	          {
	              int ii = 0;
	              while ( ii < prnSvcs.length )
	              {
	            	  System.out.println("Printer found: ["+prnSvcs[ii].getName()+"]");
	                  ii++;
	              }
	          }
	      }

Any help would be much appreciated. Thanks.

- julius

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Any kind soul out there with some ideas? still stucked in it.

former_member185029
Active Contributor
0 Kudos

Hello Julius,

I have tested your code and it prints the default printer.

Now question is , how are you making use of this code on WAS server?

Can you tell how exectly are you implementing it on server side?

Ashutosh

Former Member
0 Kudos

Hi Ashutosh,

My intention is to print data to the Intermec barcode printer.

Have you tested the code in the standalone JVM or in the Netweaver WAS? If in the Netweaver WAS, what is your OS, SPs etc. Hope you don mind to share with me more.

Thanks.

- julius

former_member185029
Active Contributor
0 Kudos

Hi,

I am using WAS 2004S SP9.

I have tested your code on JVM and WAS (using webdynpro).

I get different output on both the approaches.

My OS is window.

How are you deploying this code on WAS (for example WebDynpro or JSP)?

Ashutosh

Former Member
0 Kudos

Hi Ashutosh,

I'm using WebDynpro to test it (couldnt detect any printer).

Did u manage to get the correct default printer in the WAS?

I'm hoping anyone has implemented the printing function in the Netweaver WAS can shed some lights on how to call the network printer.

Thanks.

- julius