tags:

views:

454

answers:

2

Is there a way of sending directly an "ESC" coded string to an Epson Matrix Printer connected on a USB using Java. I've tried this one using the LPT1 port successfully. However, majority of our clients are now using USB cables instead of the old parellel cables. The main problem I have is how to open the particulary USB where the printer is connected as an outputstream in Java. Thanks in advance for any tips and suggesions.

+1  A: 

This article on JSR-80 might help you. Looks like it's not trivial at all and OS dependent...

Andreas_D
+1  A: 

Since you say LPT1, I assume this is for Windows.

I don't see any 100% Java solution to this, you want to deal with hardware

JNI

You could use JNI to call some windows DLL written in a native language (C/C++/Delphi) that exports one function SendData. You could prepare the data in a temp file (random filename), and the DLL would send it to the printer then delete it.

In Java, you could use load and loadlibrary to load the DLL.

Use some readymade solutions to convert it to USB/LPT

Osama ALASSIRY