1

I would like to print a hex file on a receipt printer. For testing, I use the cmd with the command: "copy /b test.hex lpt3:"

Now I would like a java programm, which can send the test.hex to the printer, but not as graphic.

Please, can someone tell me, how I can do that?

Thanks in advance :D

Sean Patrick Floyd
  • 292,901
  • 67
  • 465
  • 588
FabianG
  • 120
  • 1
  • 2
  • 10

1 Answers1

1

I am not sure about the syntax inside the string anymore, but you can always look that up. In Principle you can do this:

Runtime.getRuntime().exec("cmd /c start copy /b test.hex lpt3:");

Here is the reference!

So if you find no way to access that custom printer directly from java you can first create that .hex file, then use exec() to send it.

reto
  • 16,189
  • 7
  • 53
  • 67
Bernd Elkemann
  • 23,242
  • 4
  • 37
  • 66
  • I dont work often with Runtime, can you tell me the command for Close, after your commandline? I have try: 1. Runtime.getRuntime().exec("cmd /c start copy /b test.hex lpt3:"); 2. Runtime.getRuntime().exec("cmd /c stop"); – FabianG Feb 10 '12 at 14:03
  • close? i dont understand what you want to close. – Bernd Elkemann Feb 10 '12 at 14:16
  • ahh, the dos-box stays open. i previously only tried `Runtime.getRuntime().exec("cmd /c start explorer");` In which case there is no dos-box. Let me try something to get that dos-box closed again... – Bernd Elkemann Feb 10 '12 at 14:18
  • `String[] commands = new String[2]; commands[0] = "cmd /c start copy a.java b.java"; commands[1] = "cmd /c start exit"; Runtime.getRuntime().exec(commands);` – Bernd Elkemann Feb 10 '12 at 14:23
  • Sure! And thanks for accepting the answer although you have to construct it yourself from the answer and the additional comment. – Bernd Elkemann Feb 11 '12 at 10:03