Urgent java print service API ?

Hi all,
I would like to use javax.print.*;
libraries but I am using jdk1.3.1, I think in jdk1.3.1
there is no javax.print.*; libraries , so how can I download the
only java print API from jdk1.4..
if anyone knows please help me..
thanks

You can't. You must upgrade your SDK to 1.4

Similar Messages

  • Java Print Service API in Java Stored Procedure (Linux)

    Hi
    We are running an Oracle 10g database on Linux and I am in the proces of developing a java stored procedure which should utilize the Java Print Service API.
    I have made a simple stored procedure to list all available printers and the DocFlavors they support (se the code below).
    My problem is that no printers are listed. I have made a standalone java app. with the same code and executed it directly on the OS level of the Linux box through the Sun JDK 1.4.2 and here I get two printers.
    Is there any specific configuration I need to do to make it work?
    I am wondering if I need to grant specific authorisations through dbms_java for it to work...?
    Any help is greatlyh appreciated.
    ************************************** CODE BEGIN *************************************
    import javax.print.DocFlavor;
    import javax.print.PrintService;
    import javax.print.PrintServiceLookup;
    import javax.print.attribute.HashPrintRequestAttributeSet;
    import javax.print.attribute.PrintRequestAttributeSet;
    public class TestPrintService {
    public TestPrintService() {
    public static void listPrinters() {
    // Get all available printers and their supported DocFlavors
    PrintService[] pservices =
    PrintServiceLookup.lookupPrintServices(null, null);
    System.out.println("Printer services: " + pservices.length);
    for (int i = 0; i < pservices.length; i++) {
    PrintService pservice = pservices;
    System.err.println("Printer: " + pservice);
    DocFlavor[] docFlavors = pservice.getSupportedDocFlavors();
    for (int j = 0; j < docFlavors.length; j++) {
    DocFlavor docFlavor = docFlavors[j];
    System.err.println("DocFlavor " + docFlavor.toString());
    System.err.println();
    ************************************** CODE END *************************************
    Cheers,
    Jacob Vennervald

    Found this on Oracle support:
    Cannot List Available Printers From The Database Using A Java Stored Procedure [ID 372694.1]
    Applies to:
    Oracle Server - Enterprise Edition - Version: 10.1.0.4.0
    This problem can occur on any platform.
    Symptoms
    Able to list available printers on a machine when running Java code outside the Database.
    When running the same Java code inside the Database as a Java Stored Procedure, no printers are found.
    Cause
    Due to security restrictions, this is expected results.
    The Java Docs state:
    "Services which are registered by registerService(PrintService) will not be included in lookup
    results if a security manager is installed and its CheckPrintJobAccess() method denies access."
    Also from the documentation it states:
    "A PrintServiceLookup implementor is recommended to check for the SecurityManager.checkPrintJobAccess() to deny access to untrusted code. Following this recommended policy means that untrusted code may not be able to locate any print services. Downloaded applets are the most common example of untrusted code."
    Using the checkPrintJobAccess(); call, it does produce a Security Exception when run inside the Database but not when run outside. The exception can be viewed within the log file found in the UDUMP directory.
    Solution
    Run the following code to confirm obtaining available __printers can not be done...__
    This is the code to create the Java Stored Procedure
    CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED "ListPrinters" AS
    import javax.print.*;
    public class ListPrinters {
    public static String AvailablePrinters(){
    String strList;
    PrintService[] pservices =PrintServiceLookup.lookupPrintServices(null,null);
    if (pservices.length > 0 )
    strList = pservices[0].getName();
    else
    strList = "No printers found";
    return strList;
    public static String listprinters() throws Exception {
    String listofprinters;
    try {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) sm.checkPrintJobAccess();
    catch (SecurityException ex) {
    System.err.println("Sorry. Printing is not allowed.");
    listofprinters = AvailablePrinters();
    return listofprinters;
    This is the PL/SQL Wrapper
    CREATE OR REPLACE FUNCTION Get_Printer_Test RETURN VARCHAR2 IS
    LANGUAGE JAVA
    NAME 'ListPrinters.listprinters() return String';
    This executes the code
    SQL> SELECT Get_Printer_Test FROM DUAL;
    GET_PRINTER_TEST
    No printers found
    This is the output found in the trace file in the UDUMP directory
    *** SESSION ID:(144.28) 2006-07-08 09:02:25.518
    Sorry. Printing is not allowed.

  • Turn off banner within Java Print Service API

    I have web services running on JBoss 4.0.5, which is running on IBM AIX 5.
    The issue I have is anytime I try to print something through Java Print Service within web services, there is always a banner, even though banner property is set to "never" on the print queue with AIX smitty. The bad news is that property value can be overwritten by applications, or by command line options with lp or lpr commands.
    Couldn't find any way or any attribute avaiable in Print Service API to diable banner printing. Currently only default attributes are used in document printing.
    Any help would be greatly appriciated!

    fermar84 wrote:
    Thanks for answering,
    Yes i totally agree with you. There is a per device basis. However you could think (and here i am letting my imagination fly) about categorizing devices, lets say all the digital cameras. Although it would still be per-device basis, some would have common commands like turn on, or turn off. Don't you think so?
    Now lets take a simple example, can a Java program turn off the computer where its running?
    Thanks in advance,
    FernandoDo I think all digital cameras expose an "on/off" API? No, I don't. Some may, they all may, but that's in no way a Java issue.
    Can a Java program turn off a PC? No. It can call native code to do so, but then it isn't Java doing the work. All of what you're talking about is very much platform-specific, and that's where Java is generally it's weakest

  • Printing chinese w/ Java Print Service API become garbled characters

    I'm using XP platform and I've a plain text file on my drive.
    Now, what I want to do is, to read the text file in, then print it, that's all.
    However, the printout become messy, just some garbled characters.
    I did try to change quite a different ways to read the file, but the printout is still messy.
    Is there anything wrong? Can somebody give me a help?
    package com.ysf.document.client.ups;
    import java.io.FileReader;
    import java.io.IOException;
    import javax.print.*;
    import javax.print.attribute.*;
    public class Class1
       public static void main(String[] args)
          String filename = "c:\\temp\\abcd.txt";
          DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
          PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
          // locate a print service that can handle it
          PrintService[] pservices = PrintServiceLookup.lookupPrintServices(flavor, aset);
          // create a print job for the chosen service
          int printnbr = 1;
          DocPrintJob pj = pservices[printnbr].createPrintJob();
          try
             int c;
             FileReader f = new FileReader(filename);
             StringBuffer buffer = new StringBuffer();
             c = f.read();
             while (c != -1)
                buffer.append((char) c);
                c = f.read();
             Doc doc = new SimpleDoc(buffer.toString().getBytes("BIG5"), flavor, null);
             pj.print(doc, aset);
          } catch (IOException ie)
             System.err.println(ie);
          } catch (PrintException e)
             System.err.println(e);
    }

    For #1, indeed, it's my overlook, I've corrected it already.
    For #2, it shows, java.lang.ArrayIndexOutOfBoundsException: 1.
    It's mainly because my printer do not support this flavor.
    My printer supports only:
    image/gif
    [B OR java.io.InputStream OR java.net.URL
    image/jpeg
    [B OR java.io.InputStream java.net.URL
    image/png
    [B OR java.io.InputStream OR java.net.URL
    application/x-java-jvm-local-objectref
    java.awt.print.Pageable OR java.awt.print.Printable
    application/octet-stream
    [B OR java.net.URL OR java.io.InputStream
    Up to now, still no solution to it. Anybody help.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Successful using Java Print Service API on Windows 32 Platform

    Hello,
    Using the JSP API supplied with JDK1.4, I was able to print successfully the following types of documents :
    1. Text
    2. GIF, JPG... (images)
    3. PostScript files.
    But could not print "HTML" files. THe problem is that the HTML files are getting printed as text files with all the HTML tags.
    Any pointers are appreciated.
    Thanks
    TJ

    You will need to load the html into something that can render html. The printer doesn't know how to do it. It just sees plain text that you are sending. Try using JTextPane or JEditorPane (I think). It can render html files for you. Then just print that component.
    1) Create JEditorPane or JTextPane.
    2) Set contents of pane as the html file or string you want to print.
    3) Use the Graphics2D API to adjust the component coordinate space to the printer coordinate space.
    4) Render the component (JEditorPane or JTextPane) on the printer.
    There is a very nice tutorial for printing components here: http://www.apl.jhu.edu/~hall/java/Swing-Tutorial/Swing-Tutorial-Printing.html.
    Hope this helps.

  • Does java print service support word docs or text files

    Can anyone tell me that java print service api allows to print word doc files or RTF files etc.

    no it doesn't.
    To print a Word Doc you need to be able to read it, and display it.
    Anything that can be displayed in, say a JPanel, can be printed, cos it's just a matter of displaying the
    image to a virtual component ( a print canvas ). Which then gets printed.
    So, because Java doesn't immediately support Ms Docs, neither does the print service.
    regards,
    Owen

  • Printing HTML with Java Printing Service(JDK1.4 beta)

    Hi there!
    I'm currently checking out the new Java Printing Service (JPS) in the new JDK1.4 beta. This looks like a very promising printing API, with amongst others printer discovery and support for MIME types - but I have some problems with printing HTML displayed in a JEditorPane.
    I'm developing an application that should let the user edit a (HTML)document displayed in a JEditorPane and the print this document to a printer. I have understood that this should be peace-of-cake using the JPS which has pre-defined HTML DocFlavor amongst others, in fact here is what Eric Armstrong says on Javaworld (http://www.javaworld.com/javaone01/j1-01-coolapis.html):
    "With JPS, data formats are specified using MIME types, for example: image/jpeg, text/plain, and text/html. Even better, the API includes a formatting engine that understands HTML, and an engine that, given a document that implements the Printable or Pageable interface, generates PostScript. The HTML formatting engine looks particularly valuable given the prevalence of XML data storage. You only need to set up an XSLT (eXtensible Stylesheet Language Transformation) stylesheet, use it to convert the XML data to HTML, and send the result to the printer."
    After one week of reasearch I have not been able to do what Armstrong describes; print a String that contains text of MIME type text/html.
    I have checked the supported MIMI types of the Print Service returned by PrintServiceLookup.lookupDefaultPrintService(). This is the result:
    DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF;
    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    aset.add(MediaSizeName.ISO_A4);
    aset.add(new Copies(2));
    PrintService[] service = PrintServiceLookup.lookupPrintServices(flavor,aset);
    if (service.length > 0) {
    System.out.println("Selected printer " + service[0].getName());
    DocFlavor[] flavors = service[0].getSupportedDocFlavors();
    for (int i = 0;i<flavors.length;i++) {
    System.out.println("Flavor "+i+": "+flavors.toString());
    Selected printer \\MUNIN-SERVER\HP LaserJet 2100 Series PCL 6
    Flavor 0: image/gif; class="[B"
    Flavor 1: image/gif; class="java.io.InputStream"
    Flavor 2: image/gif; class="java.net.URL"
    Flavor 3: image/jpeg; class="[B"
    Flavor 4: image/jpeg; class="java.io.InputStream"
    Flavor 5: image/jpeg; class="java.net.URL"
    Flavor 6: image/png; class="[B"
    Flavor 7: image/png; class="java.io.InputStream"
    Flavor 8: image/png; class="java.net.URL"
    Flavor 9: application/x-java-jvm-local-objectref; class="java.awt.print.Pageable"
    Flavor 10: application/x-java-jvm-local-objectref; class="java.awt.print.Printable"
    As you can see there is no support for text/html here.
    If anyone has a clue to what I'm missing here or any other (elegant, simple) way to print the contents of a JEditorPane, please speak up!
    Reply to: [email protected] or [email protected] or here in this forum

    Since you have 'printable' as one of your flavors, try this using a JTextPane (assuming you can dump your HTML into a JTextPane, which shouldn't be a big problem)...
    1. Have your JTextPane implement Printable
    ie. something like this:
    public class FormattedDocument extends JTextPane implements Printable 2. Read your HTML into the associated doc in the text pane.
    3. Implement the printable interface, since you have it as one of your available flavors (I'd imagine everybody has printable in their available flavors). Something like this:
    public int print(Graphics g, PageFormat pf, int pageIndex) {
            Graphics2D g2 = (Graphics2D) g;
            g2.translate((int)pf.getImageableX(), (int)pf.getImageableY());
            g2.setClip(0, 0, (int)pf.getImageableWidth(), (int)pf.getImageableHeight()); 
            if (pageIndex == 0)
                setupPrintView(pf);
            if (!pv.paintPage(g2, pageIndex))
                return NO_SUCH_PAGE;
            return PAGE_EXISTS;
        }Here's my setupPrintView function, which is executed once on page 0 (which still needs some polishing in case I want to start from page 5). It sets up a 'print view' class based on the root view of the document. PrintView class follows...
    public void setupPrintView(PageFormat pf) {
    View root = this.getUI().getRootView(this);
            pv = new PrintView(this.getStyledDocument().getDefaultRootElement(), root,
                               (int)pf.getImageableWidth(), (int)pf.getImageableHeight());Note of obvious: 'pv' is of type PrintView.
    Here's my PrintView class that paints your text pane line by line, a page at a time, until there is no more.
    class PrintView extends BoxView
        public PrintView(Element elem, View root, int w, int h) {
            super(elem, Y_AXIS);
            setParent(root);
            setSize(w, h);
            layout(w, h);
        public boolean paintPage(Graphics2D g2, int pageIndex) {
            int viewIndex = getTopOfViewIndex(pageIndex);
            if (viewIndex == -1) return false;
            int maxY = getHeight();
            Rectangle rc = new Rectangle();
            int fillCounter = 0;
            int Ytotal = 0;
            for (int k = viewIndex; k < getViewCount(); k++) {
                rc.x = 0;
                rc.y = Ytotal;
                rc.width = getSpan(X_AXIS, k);
                rc.height = getSpan(Y_AXIS, k);
                if (Ytotal + getSpan(Y_AXIS, k) > maxY) break;
                paintChild(g2, rc, k);
                Ytotal += getSpan(Y_AXIS, k);
            return true;
    // find top of page for a given page number
        private int getTopOfViewIndex(int pageNumber) {
            int pageHeight = getHeight() * pageNumber;
            for (int k = 0; k < getViewCount(); k++)
                if (getOffset(Y_AXIS, k) >= pageHeight) return k;
            return -1;
    }That's my 2 cents. Any questions?

  • Java Print Service - PDF

    I want to use the Java Print Service(JPS) API to programatically send
    PDF files to a printer. I need to send these files to the printer
    without any user intervention.
    At present i am trying to print on HP Laserjet 5100 series.
    I am able to print text files,Images (Jpeg) but have not been successfull in printing
    PDF files.
    DocFlavor flavor = DocFlavor.INPUT_STREAM.PDF;
    DocFlavor flavor =new DocFlavor("application/pdf", "java.io.InputStream");
    The error I recieve is "Invalid Flavor". I have tried sending the PDF to the
    printer using a Document Flavor of INPUT_STREAM.AUTOSENSE.
    I also tried with
    DocFlavor flavor =new DocFlavor("application/octet-stream", "java.io.InputStream");
    When I do
    this the PDF file gets sent to the printer but what actually gets
    printed is garbage (control characters, overtyping, etc...).
    It appears the printer does not directly support PDF printing. The
    interesting thing is that I if I bring up a PDF file using Adobe Reader
    and press the Print button the file does get printed successfully!
    Can someone help me explain why Adobe Reader can print the file
    successfully but I am unable to do it programattically? Can someone
    suggest a different approach to take?.
    Regards,
    Raghu

    I suspect that it is because Adobe Reader isn't trying to print using the printer's non-existent PDF support. It is probably just sending generic image data to the printer as you would if you were printing Java 2D graphics using JPS.
    - Tomas

  • Print Service API Errors

    Hi,
    I am trying to use the new print services API's, I have a code example that will complie but failes at runtime.
    I am using Wepshere develoment studio client for the Iseries (V4.00).
    Can any one help me get this example running ?
    Error Message >>
    java.lang.NoClassDefFoundError: javax/print/PrintException
    Exception in thread "main"
    java.lang.NoClassDefFoundError: javax/print/DocFlavor
    Exception in thread "main"
    Example Code >>
    import java.lang.*;
    import java.io.*;
    import javax.print.*;
    import javax.print.attribute.*;
    import javax.print.attribute.standard.*;
    import javax.print.event.*;
    public class Print01
    static FileInputStream psStream;
    public static void main(String[] args)
    try
    psStream = new FileInputStream("file.ps");
    catch (FileNotFoundException ffne)
    System.out.println(ffne.toString());
    if (psStream == null)
    return;
    DocFlavor psInFormat = DocFlavor.INPUT_STREAM.POSTSCRIPT;
    Doc myDoc = new SimpleDoc(psStream, psInFormat, null);
    PrintRequestAttributeSet aset =
    new HashPrintRequestAttributeSet();
    aset.add(new Copies(5));
    // aset.add(MediaSize.A4);
    aset.add(Sides.DUPLEX);
    PrintService[] services =
    PrintServiceLookup.lookupPrintServices(psInFormat, aset);
    if (services.length > 0)
    DocPrintJob job = services[0].createPrintJob();
    try
    job.print(myDoc, aset);
    catch (PrintException pe)
    System.out.println(pe.toString());
    Thanks

    Looks like a runtime CLASSPATH problem...
    Try to include this code in your main, and check that the version is the same as the one expected:
       System.out.println("JAVA VERSION  IS: " + System.getProperty("java.version"));

  • Java print services  UnsatisfiedLinkError

    i'm try to run the program given with java print services guide
    i.e PrintPS.java...
    and got this error...any idea what went wrong...
    Exception in thread "main" java.lang.UnsatisfiedLinkError: getDefaultPrinterName
    at sun.print.Win32PrintServiceLookup.getDefaultPrinterName(Native Method
    at sun.print.Win32PrintServiceLookup.getDefaultPrintService(Win32PrintSe
    rviceLookup.java:198)
    at sun.print.Win32PrintServiceLookup.getPrintServices(Win32PrintServiceL
    ookup.java:61)
    at sun.print.Win32PrintServiceLookup.getPrintServices(Win32PrintServiceL
    ookup.java:157)
    at javax.print.PrintServiceLookup.getServices(PrintServiceLookup.java:35
    9)
    at javax.print.PrintServiceLookup.lookupPrintServices(PrintServiceLookup
    .java:105

    I also have this same problem. Please help me out when you got the solution. my email address: [email protected]
    Thanks.

  • Printing Service API

    Since there appears to be no "printing" forum I assume it is ok to ask in the "advanced" forum?
    I am following the first example in the JPS API User Guide. I am trying to print a file I wrote with a FileWriter class. I'm having two problems (at least that I know about).
    First, when I call PrintServiceLookup.lookupPrintServices() nothing is returned to the array. When I call PrintServiceLookup.lookupDefaultPrintService() my printer is returned. It is an HP4000 attached to a network via jetdirect.
    Secondly, when I use the default print service I try to wrap the file in a FileReader class and pass that to the SimpleDoc (Using DocFlavor.READER.TEXT_PLAIN) but when I call the DocPrintJob.print() function I get a blank sheet of paper.
    Does anybody have a clue what I am missing, why the example wouldn't work?
    TIA
    Chuck Davis

    Chuck - there are other threads on this topic which might help - i posted a thread on it myself just yesterday. There are bugs in the JPS demo and errors in the docs - i have been in touch with the author (Rajesh) who is going to correct them.
    I didnt have the specific problem that you describe although it doesnt surprise me. I was getting patchy results from the supporteddocflavour method.

  • Can't locate any printers (w/ Java Print Service)

    Hi all,
    I'm using the following code to locate print services on my Windows 2000 laptop:
    private PrintService[] drucker;
    private DocFlavor format = DocFlavor.INPUT_STREAM.TEXT_HTML_HOST;
    private Doc output;
    private PrintRequestAttributeSet printerAttributes;
    private FileInputStream stream;
    public PrintHandler() {
    printerAttributes = new HashPrintRequestAttributeSet();
    printerAttributes.add(OrientationRequested.LANDSCAPE);
    printerAttributes.add(MediaSizeName.ISO_A4);
    drucker = PrintServiceLookup.lookupPrintServices(format, printerAttributes);
    Although there are several printers installed my app can't find any. I'm pretty sure that they support the attributes.
    What am I doing wrong?
    Thanks for your help,
    Ulf Moehring

    try this:
    PrintService[] availableServices = PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);That will give you a list of all printable printers.
    Then if you wish, you can do:
    javax.swing.DefaultComboBoxModel printerCM = new javax.swing.DefaultComboBoxModel();
    for(int i = 0; i < availableServices.length; i++) {
        printerCM.addElement(availableServices.getName());
    comboBoxPrinter.setModel(printerCM);
    Hope that helps,
    James.

  • Help needed in Java Printing Service

    I need to print an image using the new JPS API, but with specific requirements.
    I managed to find out how to get the image printed from my HD onto the printer by using the example given in the JPS user guide. But I can't seem to find out how to achieve the most important requirement.
    I need to be able to control the printing position as well as the printed size of the image. Can anyone help me with it? I can't seem to find proper documentation that is related to the topic.
    Thanks in advance.

    I tried using the MediaSize class by constructing a custom sized media. But when I compiled it, I kept getting a "cannot resolve symbol" error for MediaSize.
    Then returning to the MediaSize documentation page, it said that it is not yet used to specify media. Does that mean I have to wait?
    The other thing is, I tried another approach using the java.awt.print package. Can you help me out with this piece of code, how do I correct it :
    Paper paper = new Paper();
    PageFormat page = new PageFormat();
    paper.setImageableArea(0,0,600,800);
    page.setPaper(paper);
    DocPrintJob printJob = pservices[0].createPrintJob(); *
    printJob.setPrintable(this,page);
    I am using the javax.print package on the * line, but the rest is from the java.awt.print method. However, I kept getting a "non-static variable cannot be referenced from a non-static context" error.
    What's wrong? Thanks.

  • Java Printing Service (JPS) How to get printer status and pending jobs list

    Hi,
    I am trying to determine what is the current status of a printer in my computer as well as what is the list of pending printing jobs at any moment.
    I want to monitor activity on a printer in my computer, so I can capture and log the jobs that are sent to my printer over time.
    I would like to do so by monitoring the printer pending jobs list (if that can be retrieved through any java method) and make a log of changes in that list.
    Any advice on how to get the list of pending jobs of a printer?
    I checked the API and JobState class seems to be a descriptor of one single job... I suppose the method to retrieve a list of pending jobs in a printer would return an array of JobState objects... but I have not being able to find yet such method...
    Thanks in advance,
    JN

    Moderator Action:
    This post has been moved from the Java Programming,
    to the ADF forum, for closer topic alignment.
    *... and Comment:*
    Get help from people that work with ADF.
    They may have already done something like this.

  • Java print service + print specific page

    is there anybody know how to print specific page to the printer in java?
    i am using below code. it able to print any txt file from page 1 to n. it just cannot work on printing on specific page??
    code
    String fileName = "NORMAL.txt";
         DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
    //DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PAGEABLE;
         FileInputStream pclStream = new FileInputStream(fileName);
         PrintRequestAttributeSet attributes2 = new HashPrintRequestAttributeSet();
         //attributes2.add(new Copies(1));
         Doc doc = new SimpleDoc(pclStream, flavor, null );
         PrintService[] services = PrintServiceLookup.lookupPrintServices( null, attributes2);
         PrintService service = ServiceUI.printDialog(null,50,50,services,services[0],null, attributes2 );
         if(service != null) {
         DocPrintJob dpj = service.createPrintJob();
         dpj.print(doc,attributes2);

    See it!!!
    bye bye
    import javax.print.DocFlavor;
    import java.io.FileInputStream;
    import javax.print.attribute.HashPrintRequestAttributeSet;
    import javax.print.attribute.PrintRequestAttributeSet;
    import javax.print.SimpleDoc;
    import javax.print.PrintService;
    import javax.print.ServiceUI;
    import javax.print.Doc;
    import javax.print.PrintServiceLookup;
    import javax.print.DocPrintJob;
    import java.io.File;
    import java.awt.GraphicsConfiguration;
    import java.awt.Rectangle;
    import java.awt.GraphicsEnvironment;
    import java.awt.GraphicsDevice;
    public class Untitled1 {
    public Untitled1() {
    try {
    Rectangle virtualBounds = new Rectangle();
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    GraphicsConfiguration gc = gd.getDefaultConfiguration();
    String fileName = "NORMAL.txt";
    DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
    FileInputStream pclStream = new FileInputStream(fileName);
    PrintRequestAttributeSet attributes2 = new HashPrintRequestAttributeSet();
    Doc doc = new SimpleDoc(pclStream, flavor, null );
    PrintService[] services = PrintServiceLookup.lookupPrintServices( flavor, attributes2);
    PrintService service = ServiceUI.printDialog(gc,50,50,services,services[0],flavor, attributes2 );
    if(service != null) {
    DocPrintJob dpj = service.createPrintJob();
    dpj.print(doc,attributes2);
    catch (Exception err) {
    public static void main(String[] args) {
    Untitled1 untitled11 = new Untitled1();
    }

Maybe you are looking for

  • DUAL MONITOR DISPLAYS

    Anyone know of a way to keep the second monitor active when an application on my iMac screen is set to use "Full screen" mode. I can be anything from a game application to Aperture or even YouTube videos; any full screen mode seems to do it. I bought

  • Oracle OpenWorld 2010 Update: Tuesday

    Oracle Certification update from Moscone Center: (video - 1:30) http://blogs.oracle.com/certification/2010/09/0370a.html

  • How can I force PDF's to open in IE?

    I have Windows 7 machines with IE8, Reader 11 with current patches.  No matter what setting I choose in manage add-ons, PDF's open in Adobe Reader, instead of in IE.  I have reset IE, repaired Adobe Reader and verified settings many times.  How can I

  • 2.1 Autogenerate GROUP BY and anlaytic functions

    I love the auto-generate group by feature, but I use analytic functions more frequently these days and that makes the feature a little less usable. Would it be possible for SQLDeveloper to remove a group by that is automatically added if when the OVE

  • How to make Customized mail template

    Hello Experts, My requirement is to write a mail template with the below conditions- In the Rfx collaborator list if one specific person exists then send a specific mail  for approval ,  and for others send another mail for approval . Can it be done