Help please - printing !!!!!!!!!

I wrote the below test code to print to a printer. It displays print dialog. But once i click on the ok button it throws below exception.
java.lang.ArrayIndexOutOfBoundsException: 0 >= 0
Here is the code
public class PrintTest
public static void main(String[] args) throws PrinterException {
try{
String path = "C:\\milife\\test.java";
PrinterJob pj = PrinterJob.getPrinterJob();
pj.setJobName(path);
pj.setCopies(1);
pj.printDialog();
pj.print();
catch (Exception e){System.out.println(e);}
Can anybody pls tell me what is going wrong?
Thanx,
Neha

First of all you cannot throw an Excpetion from the main() method. It makes no sense since the main() method that is used as a "GUI" even that it is a prompt. Therefore you have to handle the exceptions yourself without parsing on any exceptions to the user. (the person that is using the main() method)
If you really need to throw the PrinterException then make a method on a Class which you instantiate and call from the main() method.
Following these guidelines should solve your problem.
Regards,
Jess

Similar Messages

  • Help please, Printing to HP1100 via Dlink DP300U server mixed results

    First off, We are new to Mac.
    We have an I Mac, and our trusty old HP Laserjet 1100 printer which we are going to share with the pc.
    We installed a D-Link DP-300u print server, as the printer requires a parallel cable.
    We set up the print server according to D-Link's instructions.
    Using Apple Talk, and the port address "PS-772D-P1" for LP1 on the DPU300u.
    Initial print test page worked fine, as did a letter printed from pages.
    However, printing emails, and many other documents are not working.
    When printing emails the message prints at about 1000%, printing say directions from google maps the print job ends up looking the same. both instances, the print preview window displays all things nice.
    I am assuming that the print driver for the HP 1100 is good. and is intended to be used through a print server?
    Has anyone successfully installed an HP Laserjet through a DP-300U?
    Thanks,
    Leif

    After a bit of searching, I found this thread: http://discussions.apple.com/thread.jspa?messageID=6467845&#6467845
    I've instaled the three linux hpijs files,
    removed my printer,
    rebooted,
    installed the printer using the three Linux hpijs drivers,
    and....
    So far printing has been working, I am keeping my fingers crossed that this is the solution. now, what is shown in the print preview window appears from the printer, emails, PDF files, Web pages and a power point presentation. As silly as this sounds, it is quite satisfying.

  • My iPad shows a message "Cannot find AirPrint printer". I used to use my iPad to print materials using HP wireless printer D110. Now it does not want to print. Is this because I am now using IOS 7? What should I do to solve the problem? Help please.

    My iPad shows a message "Cannot find AirPrint printer". I used to use my iPad to print materials using HP wireless printer D110. Now it does not want to print. Is this because I am now using IOS 7? What should I do to solve the problem? Help please.

    Restart your WiFi router and printer by removing power for 30 seconds.

  • My iphone 4S will not find my printer for printing from my iphone why can anyone help please

    My I phone 4s is switched on to e print but cannot find tany air printers on any Apple devices that I have

    Hey tomohawk122,
    Have any of the Apple devices worked before?  I'll post a few questions, and a document you can try, please let me know how it goes
    1. Have you had a chance to try steps like power resetting the router and the apple devices?
    2. how far away is the router from your ipad usually?
    3. which printer do you have?
    Please try the steps in this doc, under "no airprinters found" http://h10025.www1.hp.com/ewfrf/wc/document?cc=us&dlc=en&docname=c02623193&jumpid=reg_r1002_usen&lc=...
    Cheers,
    *** If my reply was helpful, please click on the "Kudos Thumbs-Up" on the right, as a way to say "Thanks!".
    If this reply also fixed your issue - please click the "Accept as Solution" button, so that others can find the same answer. ***

  • Just updated the latest Epson software printer update from Apple. Now all my prints look solarized. How do I get rid of the new update and go back to the perfect prints I had before? Help please.

    Just updated the latest Epson software printer update from Apple. Now all my prints look solarized. How do I get rid of the new update and go back to the perfect prints I had before? Help please. Wasting ink and paper at the moment!!!!!!
    I have tried the printer with my laptop (not updated) and everything is fine. It's just the beautiful 27" Imac that can no longer print.

    Might be a corrupted printer preference file ...
    Open the Finder. From the Finder menu bar click Go > Go to Folder
    Type this exactly as you see it here:
    ~/Library/Preferences
    Click Go
    Move the com.apple.PrinterPrefs.plist file from the Preferences folder to the Trash.
    Restart your Mac, restart the printer...

  • On my HP printer Officejet4620 I get an error message "waiting for printer to become available".  Help please?

    On my HP printer Officejet4620 I get an error message "waiting for printer to become available".  Help please?

    Restart the computer and restart the printer. If you continue to have the problem the follow the steps Apple outlines in Reset Printing System feature article.

  • HP Photosmart Premium c309g-m does not have a mirror image print option-help please

    After twice being dropped from HP chat support I have laned in this forum to get some help please.
    I need to be able to print mirror images from my printer and it simply is not a option-it's not a matter of turning on the
    option, it is not there at all.
    Thanks
    Donna

    Check the iron-on packaging for ink specs.   Make sure to use HP iron-on paper.
    Say thanks by clicking "Kudos" "thumbs up" in the post that helped you.
    I am employed by HP

  • TS4212 can anyone help please..  since iCloud  came on the scene  My all in one printer  keeps saying  it is not USB connected.  I have been  looking for over a week now   and even chatted  with the USA  but cannot get it to work

    can anyone help please..  since iCloud  came on the scene  My all in one printer  keeps saying  it is not USB connected.   what do I do
    I have been  looking for over a week now   and even chatted  with the USA  but cannot get it to work.
    I am really struggling

    Thanks
    someone named  Eloisa   she gave me   a phone no.   or visit hp.com/uk
    cannot make head nor tale of it all.  I am old.  and find everything hard to undertstand

  • DEP Print Crash (Reader 9.3.2) - Help please?

    Help please anyone?
    Window DEP (Deta Execution Protection) stops me printing pdfs and the print crashes.
    If I tick/check DEP to allow me to use Reader 9 that makes NO difference even though it says if should.
    I'm using Reader 9.3.2 - not an earlier version - and the print crash happens either in Reader, using it alone, or when I open a pdf in IE or Firefox.
    I am running XP SP3, recently updated from SP2   (there maybe a connecton - was it the XP3 update which did it?)
    This is very frustrating. I don't want to abandon Adobe Reader and use a different company's  program but I have wasted hours so far tring to find a fix for this.
    Incidentally fiddling with Javascript [Reader>Edit>Preferences>Untick Enable Acrobat JavaScript] which is one recommended fix whichdoesn't work.
    Maybe there any other files I can get DEP to ignore? (NB they all have to be .exe files so be sure to tell me where to find them!)
    All advice gratefully received. I am SOooo fed up with this.
    Thanks!

    All I know is that I can't print from Adobe Reader any more but I can print pdfs since I replaced it with Foxit Reader.
    I suspect this is maybe connected with my XP upgrade from SP2 to SP3.
    I knew it might mess things up and this happened soon after. I also can't print AT ALL from Firefox now and that happened at the same time too.
    Microsoft again....? Who knows. I have solved my pdf printing problem a roundabout way, but not my Firefox problem - tho that isn't for this forum!

  • I'm using windows 7 and working in office 2010. I have installed iCloud and I can't print my calendar from outlook all it will print is a blank calendar no appointments or birthdays . can anyone help please.

    I’m using windows 7 and working in office 2010. I have installed iCloud and I can’t print my calendar from outlook all it will print is a blank calendar no appointments or birthdays . can anyone help please.
    Geoff

    I had a similiar problem, with my multiple devices.  I open iTunes and when all devices were connected I went to the info section on each device.  Under info I checked the sync calandars. Under that I click all calanders. I then did the apply in low right. I then did the sync function and it fixed it for me.  You have to do this for each device.
    I also checked the device (ipad,Iphone) themselves and change the calander selection to NO Catagory.  Hope this helps.

  • Help please can only print grey

    i am using a canon bjc80 which when i test print it prints all colours and black
    but when i print from pages or even word every thing is printed in grey i cannot find what i am doing wrong any help please
    thanks in advance

    You didn't say, so I'll ask - have you looked at all the options in the Copies & Pages pull-down menu?

  • Adobe Reader 10.1.3 won't print - and Adobe won't talk to me on the phone.... help please....

    Adobe Reader 10.1.3 won't print - and Adobe won't talk to me on the phone.... help please....

    There isn't free support for free software, but perhaps we can help.
    Please let us know
    * Your system (e.g. Windows 7)
    * What happens when you try to print, including messages in full.

  • About Ready To Throw Printer In The Trash!! Cartridge Issues!! Help Please:)

    I have an all in one 3135 Photosmart. I can scan fine, the issues are related to printing. I have the blinking top 2 lights only, the check paper and check cartridge. I went thru all the online troubleshooting steps. I do get an error on my computer that says carriage jam but the carriage moves freely and there is no paper inside. 
    Also... I feel like a real idiot now... why do I have FOUR print cartridges? There are two on the carriage itself and two on the right side of the printer. I used to be a systems manager but I've had a stroke and now things like this are causing my mind to just blank. 
    I tried to follow the steps to remove the two print cartridges on the carriage but I can only unseat them, not remove them at all. 
    Somebody help please... I am probably doing something incredibly stupid. Thanks!!! 

    The cartridges are only accessible for replacement on the right side of the printer.  It is possible an extra set of cartridges have been installed in the right side slot while there were still cartridges in the carriage.  Your printer only holds two cartridges, if there are four installed I would suggest you remove the two in the right side, then turn on the printer, open the carriage access door and allow the carriage to move to the right to change the cartridges in the printer.  At this point both sets of cartridges may be damaged, as they may have sat from some time outside the protective caps.  You may need to run a few cleaning cycles after the cartridges are reseated properly.
    The video here may help resolve the issue.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • My printer -photosmart plus B210a prints but the photos are very very dark HELP please

    I have a Hp photosmart plus B210a just trying to print out some photos and they are very very dark The photos themselves are light and of a high Dpi any suggestions anyone ??? please they are of my son's wedding so are very important to me 

    What program are you printing from? What operating system? What are the printer settings for paper type and quality?
    If you are printing from a program that allows selection of CMYK or RGB printing then select the RGB setting.  Even though the inks are CMYK the driver is expecting RGB data.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • Please help my printer talk to my computer. An error message always occurs when I try to print and Firefox self-help has not fixed the problem. Please help me directly with fixing the issue. Thank you.

    Please help my printer talk to my computer. An error message pops up whenever I try to print. I have tried the firefox self-help on this topic and it doesn't work. I need direct help with this problem.

    message is: "an unknown error occurred while printing" with the yellow icon and exclamation point. this is all it says every time.

Maybe you are looking for