From: cyber sana on
Dear Experts,

One week ago i ask about this and still cannot find the solution.

Problem:
In tomcat application, PrintServiceLookup cannot return any existing
printer:

PrintService[] pservices =
PrintServiceLookup.lookupPrintServices(null, null);

But when I use this statement in a single .java to run & test
independently, it can find all my printer service.

I print out java version in tomcat
Java home: /root/j2sdk1.4.2_19/jre
Java vesion: 1.4.2_19

They are the same as the one I singlely compile .java source.

Can anyone give me hint why i cannot detect any printer in Centos
tomcat 4.0.3 ?

By the way, I build the class file first in windows (using same java
version, and can detect printers in windows tomcat) and move the class
to centos tomcat. Is it related ?


Thanks.




From: John B. Matthews on
In article
<635e01c3-0d13-4439-921a-696ed998084f(a)w12g2000yqj.googlegroups.com>,
cyber sana <cybersana(a)gmail.com> wrote:

> Problem:
> In tomcat application, PrintServiceLookup cannot return any existing
> printer:
>
> PrintService[] pservices =
> PrintServiceLookup.lookupPrintServices(null, null);
>
> But when I use this statement in a single .java to run & test
> independently, it can find all my printer service.
>
> I print out java version in tomcat
> Java home: /root/j2sdk1.4.2_19/jre
> Java vesion: 1.4.2_19
>
> They are the same as the one I singlely compile .java source.
>
> Can anyone give me hint why i cannot detect any printer in Centos
> tomcat 4.0.3 ?
>
> By the way, I build the class file first in windows (using same java
> version, and can detect printers in windows tomcat) and move the
> class to centos tomcat. Is it related ?

I see that getPrintServices() mentions being "Implemented by a service
provider, used by the static methods of this class." Your finding
suggests that the PrintServiceLookup class is OS-specific.

<http://java.sun.com/j2se/1.4.2/docs/api/javax/print/PrintServiceLookup.html>

I'm not sure if it would help, but "Files in the [JAR's]
META-INF/services directory are service provider configuration files."

<http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html#Service%20Provider>

--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>