Java Print Service dont work in Linux

Hello
I Having one problem when try print in linux. Will anyone help.
The print result blank page. But in Windows print ok.
See the code
import java.awt.geom.*;
import java.awt.font.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.print.PrinterJob;
import java.awt.event.*;
import java.awt.*;
import java.awt.print.*;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
public class ShapesPrint extends Panel implements Printable, ActionListener {
     final static Color bg = Color.white;
     final static Color fg = Color.black;
     final static Color red = Color.red;
     final static Color white = Color.white;
     final static BasicStroke stroke = new BasicStroke(2.0f);
     final static BasicStroke wideStroke = new BasicStroke(8.0f);
     final static float dash1[] = { 10.0f };
     final static BasicStroke dashed = new BasicStroke(1.0f,
               BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f);
     final static Button button = new Button("Print");
     public ShapesPrint() {
          setBackground(bg);
          button.addActionListener(this);
     public void actionPerformed(ActionEvent e) {
          if (e.getSource() instanceof Button) {
               PrinterJob printJob = PrinterJob.getPrinterJob();
               PrintRequestAttributeSet pg = new HashPrintRequestAttributeSet();
               printJob.setPrintable(this);
               if (printJob.printDialog(pg)) {
                    try {
                         printJob.print(pg);
                    } catch (Exception PrintException) {
                         PrintException.printStackTrace();
     public void paint(Graphics g) {
          super.paint(g);
          Graphics2D g2 = (Graphics2D) g;
          drawShapes(g2);
     public void drawShapes(Graphics2D g2) {
          Dimension d = getSize();
          int gridWidth = 400 / 6;
          int gridHeight = 300 / 2;
          int rowspacing = 5;
          int columnspacing = 7;
          int rectWidth = gridWidth - columnspacing;
          int rectHeight = gridHeight - rowspacing;
          Color fg3D = Color.lightGray;
          g2.setPaint(fg3D);
          g2.drawRect(80, 80, 400 - 1, 310);
          g2.setPaint(fg);
          int x = 85;
          int y = 87;
          //draw Text Layout
          FontRenderContext frc = g2.getFontRenderContext();
          Font f = new Font("Times", Font.BOLD, 24);
          String s = new String("24 Point Times Bold");
          TextLayout tl = new TextLayout(s, f, frc);
          g2.setColor(Color.green);
          tl.draw(g2, x, y - 10);
          // draw Line2D.Double
          g2.draw(new Line2D.Double(x, y + rectHeight - 1, x + rectWidth, y));
          x += gridWidth;
          // draw Rectangle2D.Double
          g2.setStroke(stroke);
          g2.draw(new Rectangle2D.Double(x, y, rectWidth, rectHeight));
          x += gridWidth;
          // draw  RoundRectangle2D.Double
          g2.setStroke(dashed);
          g2
                    .draw(new RoundRectangle2D.Double(x, y, rectWidth, rectHeight,
                              10, 10));
          x += gridWidth;
          // draw Arc2D.Double
          g2.setStroke(wideStroke);
          g2.draw(new Arc2D.Double(x, y, rectWidth, rectHeight, 90, 135,
                    Arc2D.OPEN));
          x += gridWidth;
          // draw Ellipse2D.Double
          g2.setStroke(stroke);
          g2.draw(new Ellipse2D.Double(x, y, rectWidth, rectHeight));
          x += gridWidth;
          // draw GeneralPath (polygon)
          int x1Points[] = { x, x + rectWidth, x, x + rectWidth };
          int y1Points[] = { y, y + rectHeight, y + rectHeight, y };
          GeneralPath polygon = new GeneralPath(GeneralPath.WIND_EVEN_ODD,
                    x1Points.length);
          polygon.moveTo(x1Points[0], y1Points[0]);
          for (int index = 1; index < x1Points.length; index++) {
               polygon.lineTo(x1Points[index], y1Points[index]);
          polygon.closePath();
          g2.draw(polygon);
          // NEW ROW
          x = 85;
          y += gridHeight;
          // draw GeneralPath (polyline)
          int x2Points[] = { x, x + rectWidth, x, x + rectWidth };
          int y2Points[] = { y, y + rectHeight, y + rectHeight, y };
          GeneralPath polyline = new GeneralPath(GeneralPath.WIND_EVEN_ODD,
                    x2Points.length);
          polyline.moveTo(x2Points[0], y2Points[0]);
          for (int index = 1; index < x2Points.length; index++) {
               polyline.lineTo(x2Points[index], y2Points[index]);
          g2.draw(polyline);
          x += gridWidth;
          // fill Rectangle2D.Double (red)
          g2.setPaint(red);
          g2.fill(new Rectangle2D.Double(x, y, rectWidth, rectHeight));
          g2.setPaint(fg);
          x += gridWidth;
          // fill RoundRectangle2D.Double
          GradientPaint redtowhite = new GradientPaint(x, y, red, x + rectWidth,
                    y, white);
          g2.setPaint(redtowhite);
          g2
                    .fill(new RoundRectangle2D.Double(x, y, rectWidth, rectHeight,
                              10, 10));
          g2.setPaint(fg);
          x += gridWidth;
          // fill Arc2D
          g2.setPaint(red);
          g2.fill(new Arc2D.Double(x, y, rectWidth, rectHeight, 90, 135,
                    Arc2D.OPEN));
          g2.setPaint(fg);
          x += gridWidth;
          // fill Ellipse2D.Double
          redtowhite = new GradientPaint(x, y, red, x + rectWidth, y, white);
          g2.setPaint(redtowhite);
          g2.fill(new Ellipse2D.Double(x, y, rectWidth, rectHeight));
          g2.setPaint(fg);
          x += gridWidth;
          // fill and stroke GeneralPath
          int x3Points[] = { x, x + rectWidth, x, x + rectWidth };
          int y3Points[] = { y, y + rectHeight, y + rectHeight, y };
          GeneralPath filledPolygon = new GeneralPath(GeneralPath.WIND_EVEN_ODD,
                    x3Points.length);
          filledPolygon.moveTo(x3Points[0], y3Points[0]);
          for (int index = 1; index < x3Points.length; index++) {
               filledPolygon.lineTo(x3Points[index], y3Points[index]);
          filledPolygon.closePath();
          g2.setPaint(red);
          g2.fill(filledPolygon);
          g2.setPaint(fg);
          g2.draw(filledPolygon);
     public int print(Graphics g, PageFormat pf, int pi) throws PrinterException {
          if (pi >= 1) {
               return Printable.NO_SUCH_PAGE;
          Graphics g2 = button.getGraphics();
          button.printAll(g2);
          drawShapes((Graphics2D) g);
          return Printable.PAGE_EXISTS;
     public static void main(String s[]) {
          WindowListener l = new WindowAdapter() {
               public void windowClosing(WindowEvent e) {
                    System.exit(0);
               public void windowClosed(WindowEvent e) {
                    System.exit(0);
          Frame f = new Frame();
          f.addWindowListener(l);
          Panel panel = new Panel();
          f.add(BorderLayout.SOUTH, panel);
          f.add(BorderLayout.CENTER, new ShapesPrint());
          panel.add(button);
          f.add(BorderLayout.SOUTH, panel);
          f.setSize(580, 500);
          f.show();
}

Hi, Frank.
Thanks for your interest.
The problem is , the browsers dont compare the certificates of webutil.jar and jacob.jar with its certificate list.
In Linux the browser, Mozilla 1.7.8, look for the certificates in
/usr/lib/jvm/java-1.4.2-ibm-1.4.2.0/jre/lib/security/cacerts
In this file 'cacerts' are storing all the certificates, also exist another certs file in the home user directory the tree began in .java, but it is only a copy of the cacerts file locate in /usr/lib/jvm/java-1.4.2-ibm-1.4.2.0/jre/lib/security
Duncan Mills resolve this question in this forun post
Certificate in Linux
But I have store the keystore file, named keystore, in this subdirectory , and dont work.
Also I have copy the keystore file with the name cacerts in that subdirectory but then the java console say that it is in wrong format.
I clean the jar cache before any test and delete the .java tree in home user too.
Now Im trying to know what is the item in webutil*.htm that load the keystore file to see the way that I can force the webutiljpi.htm to load the certificate.
Any idea?
Thanks for your interest and for your help.
Regards.

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.

  • JavaRMI example is good betwen windows but dont work under linux

    Hello all, this is my first post here, Im from mexico, then, my english is not good, but i will try to explain my problem and I hope you undertand. Well, first all, Im using ubuntu 8.04 and version of JDK: java-6-sun-1.6.0.10.
    I have this code on the server:
    public class RmiServidor extends UnicastRemoteObject implements     InterfazReceptorMensajes {     
         private Registry registro;
              public RmiServidor() throws RemoteException {
              try {
    // System.setProperty("java.security.policy", "/home/gerardo/Escritorio/msdos/java.policy");
    // System.setProperty("java.rmi.server.codebase", "file://home/gerardo/Escritorio/msdos/");
    // if (System.getSecurityManager()==null)
    // System.setSecurityManager(new RMISecurityManager());
         registro = LocateRegistry.createRegistry(3232);
                   registro.rebind("rmiServidor192.168.1.2", this);
                   System.out.println("Server ok");
              } catch (RemoteException e) {
                   throw e;
         public String recibirMensaje(String cadena) throws RemoteException {
         System.out.println("El cliente dice "+cadena);
         return "Hola "+cadena;
         public static void main(String[] args) {
              try {
                   new RmiServidor();
              } catch (Exception e) {
                   e.printStackTrace();
                   System.exit(1);
    this code on the client:
    public class RmiCliente{
    InterfazReceptorMensajes rmiServidor;
    Registry registro;
    public RmiCliente() throws IOException {
         conectarseAlServidor();
    public void conectarseAlServidor() {
    try {
    // System.setProperty("java.security.policy", "/home/gerardo/Escritorio/msdos/java.policy");
    // System.setProperty("java.rmi.server.codebase", "file://home/gerardo/Escritorio/msdos/");
    // if (System.getSecurityManager()==null)
    // System.setSecurityManager(new RMISecurityManager());
    registro = LocateRegistry.getRegistry("192.168.1.2",3232);
    rmiServidor = (InterfazReceptorMensajes) (registro.lookup("rmiServidor192.168.1.2"));
    } catch (RemoteException e) {
    System.out.println("Remote Exception");
    } catch (NotBoundException e) {
    e.printStackTrace();
    this code on the interface:
    public interface InterfazReceptorMensajes extends Remote
         String recibirMensaje(String cadena) throws RemoteException;
    and another class with a bite of code:
    try{
    RmiCliente rmi = new RmiCliente();
    System.out.println(rmi.rmiServidor.recibirMensaje(" como estas "));
    }catch(IOException es){
    System.out.println("there is a exception");
    Then, when i run the server on the first windows machine, and the client on the linux machine, all works ok!
    on the server:
    -El cliente dice como estas
    on the client:
    -Hola como estas
    but, when I run the server on the linux machine, and the client on the windows machine,
    on the server:
    on the client
    -there is a exception
    I hope you can help me.
    I have the same problem when I work with 2 linux machines, dont works the client and neither the server
    but with 2 windows, the 2 machines work ok!

    Thanks a lot!!!
    well, the exception is the further:
    java.rmi.ConnectException: Connection refused to host: 127.0.1.1; nested excepti
    on is:
    java.net.ConnectException: Connection refused: connect
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
    at sun.rmi.server.UnicastRef.invoke(Unknown Source)
    at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(Unkn
    own Source)
    at java.rmi.server.RemoteObjectInvocationHandler.invoke(Unknown Source)
    at $Proxy0.recibirMensaje(Unknown Source)
    at RmiCliente.main(RmiCliente.java:32)
    Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(Unknown Source)
    at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.<init>(Unknown Source)
    at java.net.Socket.<init>(Unknown Source)
    at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown S
    ource)
    at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown S
    ource)
    ... 8 more
    I read that making something like: System.setProperty("java.rmi.server.hostname", "192.168.1.2"), but i dont know how to apply it.
    I tried to do this:
    System.setProperty("java.security.policy", "java.policy");
    System.setProperty("java.rmi.server.codebase", "");
    System.setProperty("java.rmi.server.hostname", "192.168.1.2");
    if (System.getSecurityManager()==null)
    System.setSecurityManager(new RMISecurityManager());
    where java.police have :
    grant {
    permission java.security.AllPermission;
    I run my application with:
    javac *.java
    java RmiServidor
    and i tried to do
    javac *.java
    rmic RmiServidor
    java RmiServidor
    but dont work, the exception is same.
    Why windows works ok with the same code?, is something related with the SO?
    Thanks in advance, and an apologize for my bad english.

  • 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 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?

  • Does the HP LaserJet Pro 400 Printer M401n (CZ195A) work with Linux?

    Does the HP LaserJet Pro 400 Printer M401n (CZ195A) work with Linux?
    Thank you for your help.
    James Adrian
    {Personal Information Removed}

    Hello happy321,
    Welcome to the HP Forums.
    To get your issue more exposure I would suggest posting it in the commercial forums since this is a commercial product. You can do this at Commercial Forums.
    Thanks for your time.
    Click the “Kudos Thumbs Up" at the bottom of this post to say “Thanks” for helping!
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    W a t e r b o y 71
    I work on behalf of HP

  • 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

  • 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

  • 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 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.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Bonjour Printer Services not working on Windows 7 anymore

    I have my HP Deskjet F4450 connected via USB on my IMAC running 10.6.8.
    I have it shared with everybody can print settings and can add it to both my Windows 7 laptops using Bonjour Printer Services 2.0.2 (it sees it and I can add it)
    But when I print from Windows 7 it says that the test page is spooling but nothing happens, Nothing prints.
    I have looked at a bunch of help files, but nothing has worked for me.
    Did some Windows 7 Updates break the Bonjour printer Services application?
    Thanks for any help.
    Update:  It worked about a month ago I know from each Windows laptop.
    It prints fine from my MacBook.

    I'm having the same issue, but with a Time Capsule.  My MBA can print fine to it, but my Windows 7 desktop cannot.  It sees the printer, and things queue up but never come out.  Worked fine about a month ago but stopped.

  • Cannot Get Java Business Service to Work

    Hi,
    This is my first time using Siebel Java Business Service and I cannot get it to work.
    I followed all the steps: in
    http://www.impossiblesiebel.com/2010/04/java-business-service-jbs-tutorial.html
    1) used netbeans, Created the Java class with no package, created a jar file . I copied the jar file to my Tools/CLASSES directory
    2) added a [JAVA] entry to my local client CFG. in the
    [JAVA]
    DLL = C:\Program Files\Java\jre6\bin\client\jvm.dll
    CLASSPATH = D:\Siebel\8.1\Tools_1\CLASSES\Siebel.jar;D:\Siebel \8.1\Tools_1\CLASSES\SiebelJI_enu.jar;D:\classes;D :\Siebel\8.1\Tools_1\CLASSES\ImposSiebelXSLT.jar
    VMOPTIONS = -Xrs -Djava.compiler=NONE
    3) Created a BS based on CSSJavaBusinessService and added user property
    @class
    4) Execute the BS and I am always getting the error
    Class name incorrect or does not extend SiebelBusinessService : ImposSiebelXSLT -- JVM Exception:java.lang.UnsupportedClassVersionError: ImposSiebelXSLT : Unsupported major.minor version 51.0(SBL-EAI-05010)(SBL-EXL-00151)
    Can anyone please help!!!

    in case anyone faces a similar problem. The issue was a mismatch of java versions. I compiled with Java 7 but the jvm.dll was pointing to JRE6. When I pointed it to JRE7 it worked

  • 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.

  • 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

  • Photoshop 5.5 Print Options dont work

    I hope someone can help me because I can only print my photoshop work on A4 when I want it on A3.  Its not greyed out it doesnt respond. Strange as it was working no problem then suddenly stopped.  I am using a mac OX10.8.4 and a macbook pro. I have reloaded my printers drivers Brother DCP 6690CWP and it still doesnt work.  I would appreciate it if someone can give me a straightforward fix.  Or give me the number I can ring the helpdesk from the UK.  Thanks

    You're saying you press the [Print Settings...] button and just nothing happens?
    Sorry for the very basic question, but have you rebooted your system since this started happening?
    I'm not sure Adobe is going to be able to help you with it...  It has to do with the features provided to applications by your printer driver as part of the operating system functionality.
    Can you change settings for the printer with other apps or the preferences in the Apple menu?
    -Noel

Maybe you are looking for