FULL PRODUCT VERSION :
java version "1.5.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Windows XP service pack 2 and 2000 service pack 4
EXTRA RELEVANT SYSTEM CONFIGURATION :
The print spooler service is turned off.
A DESCRIPTION OF THE PROBLEM :
When the print spooler service is turned off and a java application calls PrinterJob.getPrinterJob().printDialog() an error occurs that cannot be caught and handled and the current thread locks up.
This may occur under other scenarios that I have not tested such as if a printer is not installed but I have not checked.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Turn off the Print Spooler service in Control Panel -> Administrative Tools -> Services
Run the example code.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
In Java 1.4.2_06 a dialog is displayed to the user with the following message:
Printing Error
Before you can print you must install a printer.
To do this click ... etc
ACTUAL -
The thread that calls the printDialog() method locks up.
When using this code from an applet the applet GUI was left in an unstable state, e.g. Could not press buttons with the mouse.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "Thread-2" java.lang.IllegalArgumentException: Invalid value for property printer or null printer port
at sun.awt.windows.WPrintDialogPeer._show(Native Method)
at sun.awt.windows.WPrintDialogPeer.access$000(WPrintDialogPeer.java:14)
at sun.awt.windows.WPrintDialogPeer$1.run(WPrintDialogPeer.java:44)
at java.lang.Thread.run(Thread.java:595)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public static void main(String[] args)
{
java.awt.print.PrinterJob.getPrinterJob().printDialog();
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Turn on the Print Spooler service in Control Panel -> Administrative Tools -> Services