J
joseph_daniel_zukiger
A quick search on Google shows that some people have had problems like
this when no valid printers were on line, or when CUPS wasn't properly
set up. So I plugged my USB printer in and turned it on, but still get
the same exception.
Netbeans does not crash, but it also does not find my valid printer. So
I'm pretty sure my printer is set up wrong, however, it would be nice
to avoid crashing without catching and ignoring the exception.
Anyone know anything about this?
Or, can anyone point me to a good tutorial on getting a valid
PageFormat without asking the machine to look for a printer?
The exception:
Exception in thread "main" java.lang.IndexOutOfBoundsException
at
java.io.BufferedInputStream.read(BufferedInputStream.java:306)
at sun.net.www.MeteredStream.read(MeteredStream.java:116)
at java.io.FilterInputStream.read(FilterInputStream.java:111)
at
sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:2123)
at java.io.DataInputStream.read(DataInputStream.java:134)
at
sun.print.IPPPrintService.readIPPResponse(IPPPrintService.java:1589)
at
sun.print.IPPPrintService.opGetAttributes(IPPPrintService.java:1436)
at
sun.print.IPPPrintService.initAttributes(IPPPrintService.java:333)
at
sun.print.IPPPrintService.getSupportedDocFlavors(IPPPrintService.java:707)
at
sun.print.IPPPrintService.isDocFlavorSupported(IPPPrintService.java:783)
at
sun.print.RasterPrinterJob.getPrintService(RasterPrinterJob.java:428)
at
sun.print.RasterPrinterJob.defaultPage(RasterPrinterJob.java:1420)
at java.awt.print.PrinterJob.defaultPage(PrinterJob.java:361)
at RandomWords$RandomWordsPage.<init>(RandomWords.java:223)
at RandomWords.main(RandomWords.java:416)
The code:
public static class MyWordsPage extends JPanel implements Printable
{
PageFormat format;
PrinterJob printJob;
MyWordsPage( String[] myWords )
{
super();
this.printJob = PrinterJob.getPrinterJob();
this.format = this.printJob.defaultPage();
...
this when no valid printers were on line, or when CUPS wasn't properly
set up. So I plugged my USB printer in and turned it on, but still get
the same exception.
Netbeans does not crash, but it also does not find my valid printer. So
I'm pretty sure my printer is set up wrong, however, it would be nice
to avoid crashing without catching and ignoring the exception.
Anyone know anything about this?
Or, can anyone point me to a good tutorial on getting a valid
PageFormat without asking the machine to look for a printer?
The exception:
Exception in thread "main" java.lang.IndexOutOfBoundsException
at
java.io.BufferedInputStream.read(BufferedInputStream.java:306)
at sun.net.www.MeteredStream.read(MeteredStream.java:116)
at java.io.FilterInputStream.read(FilterInputStream.java:111)
at
sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:2123)
at java.io.DataInputStream.read(DataInputStream.java:134)
at
sun.print.IPPPrintService.readIPPResponse(IPPPrintService.java:1589)
at
sun.print.IPPPrintService.opGetAttributes(IPPPrintService.java:1436)
at
sun.print.IPPPrintService.initAttributes(IPPPrintService.java:333)
at
sun.print.IPPPrintService.getSupportedDocFlavors(IPPPrintService.java:707)
at
sun.print.IPPPrintService.isDocFlavorSupported(IPPPrintService.java:783)
at
sun.print.RasterPrinterJob.getPrintService(RasterPrinterJob.java:428)
at
sun.print.RasterPrinterJob.defaultPage(RasterPrinterJob.java:1420)
at java.awt.print.PrinterJob.defaultPage(PrinterJob.java:361)
at RandomWords$RandomWordsPage.<init>(RandomWords.java:223)
at RandomWords.main(RandomWords.java:416)
The code:
public static class MyWordsPage extends JPanel implements Printable
{
PageFormat format;
PrinterJob printJob;
MyWordsPage( String[] myWords )
{
super();
this.printJob = PrinterJob.getPrinterJob();
this.format = this.printJob.defaultPage();
...