How to print *.PRN file without print Dialog from Java

hi friends
I need to print *.PRN file from java code.*
I need to print directely without open printer dialog box when i select .PRN file then it should able to direct print to default printer.
Here is the Dos command to directely print the PRN file
COPY C:\\PrintFile.prn /B \\java103\\HPLaserJ
(source: http://filext.com/faq/print_from_prn_file.php)
i try to run that dos command through Process p = Runtime.getRuntime().exec("COPY C:\\PrintFile.prn /B \\java103\\HPLaserJ");
But is show that
Here is the LOG of ERROR
\\java103\HP LaserJet M1120 MFP
java.io.IOException: Cannot run program "COPY": CreateProcess error=2, The system cannot find the file specified
     at java.lang.ProcessBuilder.start(Unknown Source)
     at java.lang.Runtime.exec(Unknown Source)
     at java.lang.Runtime.exec(Unknown Source)
     at java.lang.Runtime.exec(Unknown Source)
     at Print2Printer.GetDefaultPrinter.main(GetDefaultPrinter.java:17)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
     at java.lang.ProcessImpl.create(Native Method)
     at java.lang.ProcessImpl.<init>(Unknown Source)
     at java.lang.ProcessImpl.start(Unknown Source)
     ... 5 more
Here is the Source
import java.io.IOException;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
public class GetDefaultPrinter {
     public static void main(String args[]){
          PrintService printer = PrintServiceLookup.lookupDefaultPrintService();
          System.out.println(printer.getName());
          try {
               Process p = Runtime.getRuntime().exec("COPY C:\\PrintFile.prn /B \\java103\\HPLaserJ");
               System.out.println(p);
          } catch (IOException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();

you need to specify which program you want to execute in Runtime.getRuntime().exec(). So try this one
try {
Process p = Runtime.getRuntime().exec("cmd.exe COPY C:\\PrintFile.prn /B \\java103\\HPLaserJ");
System.out.println(p);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

Similar Messages

  • Print a file to printer wirelessly and without need to use CD drive to install driver?

    I have a HP-P1006 printer in my conference room and sometimes my guest want to send print to my printer and I have to connect their laptop with USB cable to my printer and install printer driver thought CD Drive. I want to know if there is a way to print a file to printer wirelessly and without need to use CD drive to install driver? (I don't have a wireless network in my conference room) 

    Is it possible to automate Adobe Reader to load files, then set the staple property and location, then print them out? I've seen in .NET 3.0 that there is a Enumeration for Stapling in the System.Printing Namespace. I need to figure out how to automate the printing in adobe but right before it prints, have .NET assign the printer and whether it should be stapled or not.

  • I am trying to delete pages I have crated in numbers, but can only see them in print preview. Without print preview I do not see them. How can I delete these pages, but keep others before and after?

    I am trying to delete pages I have crated in numbers, but can only see them in print preview. Without print preview I do not see them. How can I delete these pages, but keep others before and after?

    Hi Crushed,
    Numbers doesn't have pages. It has a canvas that holds objects such as tables and charts.
    Drag the objects from the bottom of the canvas onto the white space above. That will reduce the number of "pages" (sheets of paper) that will print.
    Regards,
    Ian.

  • How can i print an email without printing the attachment?

    I just got my new macbook pro retina display.  I am using Mac mail and want to know how I can print an email without printing the attachement.  Any suggestions and solutions would be appreciated.

    Thank you for your suggestion.  But when I receive an email that has an attachment (shown by paperclip symbol) The email opens and shows the attachment(jpg picture) at the end of the email so when I go to print - the email pops up with the picture already opened inside the body of the email.  Can not figure out why this happens in mac mail.  when i used outlook in windows only email would show.  in order to see attachment you had to click on paperclip and only then would the attachment (picture apprear).
    Any other suggestions that I may could try would be appreciated. Thank you!  Gabriela

  • Print pdf files without open them

    i am using gnome and adobe reader to open pdf file. however, is there anyway i can print the files without open them ?

    lpr somefile.pdf - as long as cups is configured correctly.

  • Anyone know how to get pdf files to print on Mac

    anyone know how to get pdf files to print on  a Mac. When i bring pdf file up and press print a box comes up saying cannot print. When i press that one another comes up saying no pages selected. Everything up to date, rebooted, checked to make sure plugins are there and up to date.

    Might not be exactly what you want and I haven't had time to fully investigate this but take a look at http://www.hanynet.com/waterroof/

  • How to view pst file without Microsoft Outlook?

    How to view pst file without Microsoft Outlook? Please suggest viewer for content of corrupted PST files.

    Hi,
    If the .pst file is corrupted, I suggest you run Scanpst.exe to repair it:
    http://support.microsoft.com/kb/272227
    If you need to view .pst file without Outlook, we may use some 3rd-party tools, there are a lot on Internet.
    Regards,
    Melon Chen
    TechNet Community Support

  • How to Attach a File Without Embedding It on Mail?

    How to Attach a File Without Embedding It on a Mac?
    Tamer is not working and I prefer not to use TERMINAL (defaults write com.apple.mail DisableInlineAttachmentViewing -bool yes)
    Right click send as icon is not a solution.
    Any other options? Thanks!

    bbp@bcn wrote:
    I always receive the same response, "Can you send it as an attachment?"
    and I think It does something to do with the way I send files.
    Thanks
    It's nothing to do with the way you send them. Every mail client chooses how to cope with attachments: in some there is a preference setting but in many cases it automatically displays embedded images. Even where there is a preference setting it's up to the person receiving the email: you can't control it. Why are they so fussed about your sending as an attachment? The image can be saved easily enough, usually by dragging it to the Desktop, or by a button to save attachments. If they really want this you are going to have to zip it, there isn't any other way round it.

  • My Office Print Pro 8600 Plus will not print pdf files sent to it from an iPad using ePrint.

    My Office Print Pro 8600 Plus will not print pdf files sent to it from an iPad using ePrint.  I just get an error message when I go to the  HP Eprint centre.  It does print the cover e-mail but nothing else.  The attachment is not secure as far as I can see.  I have tried sending an attachment from my Mac and that worked fine.
    This question was solved.
    View Solution.

    Hello krnkln3.
    Are you trying to send the PDF as an attachment in an e-mail sent to the ePrint e-mail address of the printer or are you trying to print using the ePrint app?
    Try sending the same PDF document to the printer's ePrint e-mail address and let us know if that works. If this works but using the ePrint app is not working, maybe the ePrint app is not working fine with this PDF document (it could be due to it's size or something else). Remember that you can always use the e-mail ePrint address of the printer to send PDF documents as the processing is happening at the HP servers and not in your iPad as when you try to send it using the ePrint app.
    Cheers!
    Wixma.
    I am an HP employee.
    Say thanks by clicking the Kudos star in the post.
    If my reply resolved your problem, please mark it as as Accepted Solution so that it can be found easier by other people.

  • How can I rename files without creating a duplicate?

    How can I rename files without creating a duplicate?  And secondly, for some reason I can no longer save pdf files [i.e., bank statements] where I want - the Save As function is gone?

    In many new cases, Save As is now called Duplicate in ML. It uses the same command-S keystroke. Older apps still have Save As. When you do a Duplicate operation, you will create an UNTITLED document. You have to save that duplicated document to complete the process.
    So in 10.6.x, you would do ...
    * Save As ...
    * Give the file a new name + Chose the location for the file
    * Click the Save button
    Now in 10.8.x, you do ...
    * Duplicate ...
    * Save ...
    * Give the file a name + Chose the location for the file
    * Click the Save button
    As baltwo mentioned, you have to search the Preferences of your browser to determine what is has set for the default Download folder.
    JJW

  • How do you transfer files (Music/books/pictures) from an iPAD or iPOD device to an new PC that has iTunes, but no data of files

    I have purchased an new PC since my oriiginal PC crashed after 5 years of use.  I want to transfer my iTunes files from my iPAD and iPOD to my new PC.
    How do you transfer files (Music/books/pictures) from an iPAD or iPOD device to an new PC that has iTunes, but no data of files

    The text below is copied from this discussion.
    https://discussions.apple.com/message/11527071#11527071
    Authorize your new computer's iTunes first - Store>Authorize this computer.
    1) Without connecting your iPad to your laptop, start iTunes. Click on Edit. Click on Preferences. Click on Devices. Check the box next to "Prevent your iPod etc. from automatically syncing." Click OK.
    2) Now connect your iPad to your laptop and start iTunes.
    3) When iTunes starts, right click on your iPad under Devices in the left column. Select Transfer purchases etc.
    4) After it finishes transferring all your apps to your new laptop, right click on your iPad and select Backup your iPad.
    5) After it finishes backing up your iPad, right click on your iPad and select Restore etc.
    6) After it finishes restoring, left click on your iPad , then click on the Apps tab on top, and check the box next to Sync Apps, then click on Apply below.
    If everything on your iPad looks good after the sync, go back and click on Edit / Preferences / Devices and UN-check the box next to Prevent your iPod etc. The only other thing you may want to check is if your contacts, bookmarks, etc. are syncing correctly now. If not, go to the Info tab after connecting and make sure you indicate which features you want to sync with what sources.
    This discussion has much of the same information and even some more helpful tips.
    https://discussions.apple.com/thread/3305461

  • How can i execute excelsheet without giving path in java

    Hi,
    How can i execute excelsheet without giving path in java, through this code, you can open the notepad but
    I want whereever the excel is installed in your machine , fine and open excelsheet without given absolute path.
    class ExecuteCommand{
    public static void main(String d[]){
         Runtime r = Runtime.getRuntime();
         Process p= null;
         try{
         p = r.exec("notepad");
              catch(Exception e){
                   System.out.println("error");
    If you know please send me your idea and code samples.
    regards
    Mohan kumar

    just execute the exelfile with the Windows "start" command:
    Runtime.exec("cmd /c start "+excelFileName);But this requires that Excel is the default application for the Excel file type (*.xls). You can test this by simply typing "start myTestExcel.xls" in a dos box.

  • Printing the datas through Crystal Report from Java

    How can I Print the datas through Crystal Report from java?

    How can I Print the datas through Crystal Report from
    java?
    What the hell are "the datas"?
    Jesus, I can understand this is a shrinking planet, Global community, and all that happy horse pucky. Typos or small grammar errors are no big deal, I make them all the time. But when I have to spend more time interpretting the question than figuring out the answer, it drives me crazy.

  • How can I access files that I moved from an older MacBook Pro to a newer one via Firewire and Migration assistant.  The files show up on the new MacBook but cannot be opened.  Thanks!

    How can I access files that I moved from an older MacBook Pro to a newer one via Firewire and Migration assistant?  The files show up on the new MacBook but cannot be opened.  Thanks!

    Get info then check permissions then add your curent user name (it was probably different on old Mac) and give your username full read/write permissions.

  • How to remove preinstalled files of adobe photoshop from my mac mini so that i can install a new version of the same software.The previous version was removed using the app cleaner software.Could not continue installation bcoz of earlier files

    How to remove preinstalled files of adobe photoshop from my mac mini so that i can install a new version of the same software.The previous version was removed using the app cleaner software.Could not continue installation of the new version because of the existance of files from the previous version.plz help

    What "app cleaner software" ? I ask because installing Photoshop over a previous version has never been a problem. Perhaps your difficulty stems from another source, eg. "cleaner software" ?
    If you look in your hard drive, at the root level there is a Library. In there is a folder called Application Support, and in that you will find a folder called Adobe. Files from your previous version are there.
    However, I urge you to call Adobe support to make sure you are not doing anything that would mess up other Adobe applications.
    http://www.adobe.com/support/connect/connecthostedsupport.html

Maybe you are looking for

  • How do I get my information back if my ipod touch restored itself?

    I was using instagram when all of a sudden my ipod turned off on me, and It was fully charged.  When I attempted to turn it on, the picture of a USB cord popped up pointing to itunes to plug it in a computer, like how it would show if you just purcha

  • Hints FIRST_ROWS and order by not working together

    Hi, We are facing an issue like we are using hint FIRST_ROWS with a query which have a order by clause, if we are giving both together it is not working and if we remove either order by or hint it is working SELECT /*+FIRST_ROWS*/ * FROM (SELECT MYRO

  • Bill overcharged

    The bill received had over charged twice on my account due to the connection error.Please assist.

  • Flash CC Crashes on File -- Close

    Hello, I recently upgrade from Flash CS to Flash CC and now, everytime I try to close a document I am working on -- Flash CC crashes completely and I have to restart. This happens EVERY time I open, edit, save and close an .fla file. Also -- if I try

  • BizTalk Service Pricing

    Hi, We are planning to migrate from BizTalk 2009 to BizTalk Services. Could you please answer the following questions regarding pricing: 1. Hybrid Connection Data Transfer (GB) per Unit is 250GB for standard BizTalk Unit. Is this limit (250GB) per da