harwey/cups4j

General Java PrinterJob.lookupPrintServices() problem - looking for help

Closed this issue · 2 comments

C4J commented

Firstly - apologies for posting here when it's not specifically a cups4j issue but I'm hoping your experience with Java and printers may be able to shed some light on a problem which seems to defy all logic. I do use cups4j in my project if that's a consolation but this question does not use it's API.

I have the following java statement in my code.

PrinterJob.lookupPrintServices()

I written a very simple routine which queries the print queues on my MacOS machine and prints out their names. All good and well.

If I run using the last Java 8 202 from Oracle which has compatible licences from the command line it works.

Here comes the "crunch". For my main open source project i use a packaging tool called Install4j which provides a multi platform installer and also a java application launcher.

If I use version 7 of their software my application runs fine and the gui jframe which displays the print queue lists all the printers fine. If I use v8 of their software the application still launches fine but the above statement does not return any printers.

I have googled to death all problems with the above statement and macOS/linux problems and several people have reported the same problem but no conclusion has been drawn. All theories seem to either suggest moving to Java 9 (which I cannot do yet) or having issues with DocFlavour when querying the queues.

Those theories may be valid - but in my scenario I'm running the exact same java code with the same bundled version of java (I print out the version number at the start) and I'm getting 2 results.

I've exchanged a great number of emails with the developers of install4j and they are unable to explain or understand what might cause the different behaviour between v7 and v8 of their java launcher.

So - I was hoping if you might have any insight into the MacOS / Linux Cups printing service which might shed some light on ANYTHING which could explain the different behaviour I'm seeing.

I develop on MacOS - I've created virtual machines - one with another copy of MacOS Mojave which replicates the problem and another with Centos 7 which does not show the problem.

I cannot just blame Mojave or Java as I can make the program work successfully using v7 of their launcher - but neither me or the developers have any idea what could influence the results.

Sorry for such a long email but I've totally run out of ideas and I'm hoping you might be able to throw in some fresh ideas.

Dave
install4jPrinterTest.zip

Hi Dave,
as this is kind of off topic, could you send an E-Mail to info@cups4j.org?
I would like to keep this separate from Cups4J.

Thanks
Harald

C4J commented

Just emailed you - thanks.