You can use java.io package to open the printer as file and write to it. I have
done it. If I remember it correctly I was some thing like this
File printerFile = new File("\\server\printer");
OutputStream printOut = new BufferedOutputStream(new FileOutputStream(
printerFile ));
.....
This is an easy solution for a standalone application on windows by using UNC
name for printer.
But the better way is to define the printer as a shared IP printer and then use
IP print commands to spool the job. This will work from server application also.
Good luck!
Anu Prakash
-----Original Message-----
From: Richard O. Hammer [mailto:[EMAIL PROTECTED]
Sent: Saturday, August 06, 2005 6:22 PM
To: Java Users Group
Subject: [Juglist] writing from Java to a printer on a USB port
How can I write from Java to a printer on a USB port? I just want to
send a stream of bytes to the printer, nothing fancy. I'm working on
Windows XP and using Java SDK 1.4.
On my assignment to print barcoded labels (about which I asked last
weekend) I've found that I can hack an acceptable solution by using Java
to write byte-level printer commands into a file. Then I can print on
the label printer which is connected to a serial port by opening a
Windows command prompt, and typing "copy filename com1", just like I did
it with DOS 15 years ago.
But now I've found out that this printing has to be done on a printer
which is connected to a USB port on a different Windows XP machine. So
as far as I know the "copy filename usbPortName" will not work, will it?
And besides, it would be better if I could just open an OutputStream to
that printer directly and skip the step of writing into a file. How can
I do this?
Thank you,
Rich Hammer
_______________________________________________
Juglist mailing list
[email protected]
http://trijug.org/mailman/listinfo/juglist_trijug.org
_______________________________________________
Juglist mailing list
[email protected]
http://trijug.org/mailman/listinfo/juglist_trijug.org